Transform value to type.

@param  \GraphQL\Language\AST\TypeDefinitionNode  $typeDefinition
@return \GraphQL\Type\Definition\Type

@throws \Nuwave\Lighthouse\Exceptions\DefinitionException
353964
protected function resolveType(TypeDefinitionNode $typeDefinition): Type
    {
        // Ignore TypeExtensionNode since they are merged before we get here
        switch (get_class($typeDefinition)) {
            case EnumTypeDefinitionNode::class:
                return $this->resolveEnumType($typeDefinition);
            case ScalarTypeDefinitionNode::class:
                return $this->resolveScalarType($typeDefinition);
            case ObjectTypeDefinitionNode::class:
                return $this->resolveObjectType($typeDefinition);
            case InputObjectTypeDefinitionNode::class:
                return $this->resolveInputObjectType($typeDefinition);
            case InterfaceTypeDefinitionNode::class:
                return $this->resolveInterfaceType($typeDefinition);
            case UnionTypeDefinitionNode::class:
                return $this->resolveUnionType($typeDefinition);
            default:
                throw new InvariantViolation(
                    "Unknown type for definition [{$typeDefinition->name->value}]"
                );
        }
    }
961994
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        return [
            '__identity' => $this->persistenceManager->getIdentifierByObject($source),
            '__type' => TypeHandling::getTypeForValue($source)
        ];
    }
413949
protected function getType($type)
    {
        if (isset($this->typeAlias[$type])) {
            return $this->typeAlias[$type];
        }

        return $type;
    }
1057593
public function setType($value): self
    {
        if (!in_array($value, self::types(), true)) {
            throw new DomainException(sprintf(self::UNEXPECTED_TYPE, implode(', ', self::types())));
        }

        return $this->setAttribute('type', $value);
    }
435382
protected function lexInputObjectTypeExtension(): InputObjectTypeExtensionNode
    {
        $start = $this->lexer->getToken();

        $this->expectKeyword(KeywordEnum::EXTEND);
        $this->expectKeyword(KeywordEnum::INPUT);

        $name       = $this->lexName();
        $directives = $this->lexDirectives(true);
        $fields     = $this->lexInputFieldsDefinition();

        if (empty($directives) && empty($fields)) {
            throw $this->unexpected();
        }

        return new InputObjectTypeExtensionNode($name, $directives, $fields, $this->createLocation($start));
    }
103194
public function setValue($value): FieldTypeInterface
    {
        $this->value = $this->transformer->transform($value);

        return $this;
    }
253536
public function create(string $className, string $typeName): Type
    {
        $identifiers = $this->entityManager->getClassMetadata($className)->getIdentifier();
        if (count($identifiers) > 1) {
            throw new Exception('Entities with composite identifiers are not supported by graphql-doctrine. The entity `' . $className . '` cannot be used as input type.');
        }

        return new EntityIDType($this->entityManager, $className, $typeName);
    }
938743
protected function lexExecutableDefinition(): ExecutableDefinitionNodeInterface
    {
        if ($this->peek(TokenKindEnum::NAME)) {
            // Valid names are: query, mutation, subscription and fragment
            $token = $this->lexer->getToken();

            switch ($token->getValue()) {
                case KeywordEnum::QUERY:
                case KeywordEnum::MUTATION:
                case KeywordEnum::SUBSCRIPTION:
                    return $this->lexOperationDefinition();
                case KeywordEnum::FRAGMENT:
                    return $this->lexFragmentDefinition();
            }
        } elseif ($this->peek(TokenKindEnum::BRACE_L)) {
            // Anonymous query
            return $this->lexOperationDefinition();
        }

        throw $this->unexpected();
    }
63955
protected function type(\DOMNode $node)
    {
        $type = null;
        if ($node instanceof \DOMText) {
            $type = WordType::TEXT;
        } elseif ($node instanceof \DOMAttr) {
            $type = WordType::VALUE;
        } else {
            throw new ParserCrawlerAfterListenerException('No word type set for this kind of node.');
        }
        return $type;
    }
456968
protected function convertTypeToClass($type)  {
		$type = trim($type);

		// Try direct mapping
		$class = str_replace(' ', '', ucwords($type));
		if(class_exists($class) || !($class == 'DataObject' || is_subclass_of($class, 'DataObject'))) {
			return $class;
		}

		// Fall back to singular names
		foreach(array_values(\ClassInfo::subclassesFor('DataObject')) as $candidate) {
			if(singleton($candidate)->singular_name() == $type) return $candidate;
		}

		throw new \InvalidArgumentException(sprintf(
			'Class "%s" does not exist, or is not a subclass of DataObjet',
			$class
		));
	}
1043226
public function setDefinition($definition) {
        if ($definition instanceof Definition) {
            $this->definition = $definition;
        }
        else {
            $this->definition->setDefinition($definition);
        }

        $this->consoleDefinitionMerged = false;

        return $this;
    }
708846
public function asTagged(): TaggedType
    {
        if (!$this->_element instanceof TaggedType) {
            throw new \UnexpectedValueException(
                "Tagged element expected, got " . $this->_typeDescriptorString());
        }
        return $this->_element;
    }
337621
protected static function parseDefinition($definition)
    {
        if (!is_array($definition)) {
            $definition = deserialize($definition, true);

            return $definition;
        }

        return $definition;
    }
538424
func typeDefinition() (*design.UserTypeDefinition, bool) {
	m, ok := dslengine.CurrentDefinition().(*design.UserTypeDefinition)
	if !ok {
		dslengine.IncompatibleDSL()
	}
	return m, ok
}
1335961
protected function lexType(): TypeNodeInterface
    {
        $start = $this->lexer->getToken();

        if ($this->skip(TokenKindEnum::BRACKET_L)) {
            $type = $this->lexType();

            $this->expect(TokenKindEnum::BRACKET_R);

            $type = new ListTypeNode($type, $this->createLocation($start));
        } else {
            $type = $this->lexNamedType();
        }

        if ($this->skip(TokenKindEnum::BANG)) {
            return new NonNullTypeNode($type, $this->createLocation($start));
        }

        return $type;
    }
358128
public function getTypeConverterFactory(): TypeConverterFactory
    {
        if (!$this->converterFactory) {
            $this->setTypeConverterFactory(new converters\DefaultTypeConverterFactory());
        }
        return $this->converterFactory;
    }
1221729
public function resolve(DefinitionInterface $definition)
    {
        switch (true) {
            case $definition instanceof ReferenceDefinitionInterface:
                return $this->container->get($definition->getTarget());

            case $definition instanceof ParameterDefinitionInterface:
                return $definition->getValue();

            case $definition instanceof ObjectDefinitionInterface:
                $reflection = new \ReflectionClass($definition->getClassName());

                // Create the instance
                $constructorArguments = $definition->getConstructorArguments();
                $constructorArguments = array_map([$this, 'resolveSubDefinition'], $constructorArguments);
                $service = $reflection->newInstanceArgs($constructorArguments);

                // Set properties
                foreach ($definition->getPropertyAssignments() as $propertyAssignment) {
                    $propertyName = $propertyAssignment->getPropertyName();
                    $service->$propertyName = $this->resolveSubDefinition($propertyAssignment->getValue());
                }

                // Call methods
                foreach ($definition->getMethodCalls() as $methodCall) {
                    $methodArguments = $methodCall->getArguments();
                    $methodArguments = array_map([$this, 'resolveSubDefinition'], $methodArguments);
                    call_user_func_array([$service, $methodCall->getMethodName()], $methodArguments);
                }

                return $service;

            case $definition instanceof FactoryCallDefinitionInterface:
                $factory = $definition->getFactory();
                $methodName = $definition->getMethodName();
                $arguments = (array) $definition->getArguments();
                $arguments = array_map([$this, 'resolveSubDefinition'], $arguments);

                if (is_string($factory)) {
                    return call_user_func_array([$factory, $methodName], $arguments);
                } elseif ($factory instanceof ReferenceDefinitionInterface) {
                    $factory = $this->container->get($factory->getTarget());
                    return call_user_func_array([$factory, $methodName], $arguments);
                }
                throw new InvalidDefinition(sprintf('Definition "%s" does not return a valid factory'));

            default:
                throw UnsupportedDefinition::fromDefinition($definition);
        }
    }