Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScalarTypes.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 {
19  public function isScalarType(string $typeName) : bool
20  {
21  $internalTypes = \GraphQL\Type\Definition\Type::getInternalTypes();
22  return isset($internalTypes[$typeName]) ? true : false;
23  }
24 
30  public function getScalarTypeInstance(string $typeName) : \GraphQL\Type\Definition\Type
31  {
32  $internalTypes = \GraphQL\Type\Definition\Type::getInternalTypes();
33  if ($this->isScalarType($typeName)) {
34  return $internalTypes[$typeName];
35  } else {
36  throw new \LogicException(sprintf('Scalar type %s doesn\'t exist', $typeName));
37  }
38  }
39 
46  public function createList(\GraphQL\Type\Definition\Type $definedType) : ListOfType
47  {
48  return new ListOfType($definedType);
49  }
50 
57  public function createNonNull(\GraphQL\Type\Definition\Type $definedType) : NonNull
58  {
59  return new NonNull($definedType);
60  }
61 }
createList(\GraphQL\Type\Definition\Type $definedType)
Definition: ScalarTypes.php:46
createNonNull(\GraphQL\Type\Definition\Type $definedType)
Definition: ScalarTypes.php:57