listOf() public static method

public static listOf ( $wrappedType ) : ListOfType
$wrappedType
return ListOfType
Ejemplo n.º 1
0
 /**
  * @return Schema
  */
 protected function getDefaultSchema()
 {
     $Being = new InterfaceType(['name' => 'Being', 'fields' => ['name' => ['type' => Type::string()]]]);
     $Pet = new InterfaceType(['name' => 'Pet', 'fields' => ['name' => ['type' => Type::string()]]]);
     $DogCommand = new EnumType(['name' => 'DogCommand', 'values' => ['SIT' => ['value' => 0], 'HEEL' => ['value' => 1], 'DOWN' => ['value' => 3]]]);
     $Dog = new ObjectType(['name' => 'Dog', 'fields' => ['name' => ['type' => Type::string()], 'nickname' => ['type' => Type::string()], 'barkVolume' => ['type' => Type::int()], 'barks' => ['type' => Type::boolean()], 'doesKnowCommand' => ['type' => Type::boolean(), 'args' => ['dogCommand' => ['type' => $DogCommand]]], 'isHousetrained' => ['type' => Type::boolean(), 'args' => ['atOtherHomes' => ['type' => Type::boolean(), 'defaultValue' => true]]], 'isAtLocation' => ['type' => Type::boolean(), 'args' => ['x' => ['type' => Type::int()], 'y' => ['type' => Type::int()]]]], 'interfaces' => [$Being, $Pet]]);
     $FurColor = new EnumType(['name' => 'FurColor', 'values' => ['BROWN' => ['value' => 0], 'BLACK' => ['value' => 1], 'TAN' => ['value' => 2], 'SPOTTED' => ['value' => 3]]]);
     $Cat = new ObjectType(['name' => 'Cat', 'fields' => ['name' => ['type' => Type::string()], 'nickname' => ['type' => Type::string()], 'meows' => ['type' => Type::boolean()], 'meowVolume' => ['type' => Type::int()], 'furColor' => ['type' => $FurColor]], 'interfaces' => [$Being, $Pet]]);
     $CatOrDog = new UnionType(['name' => 'CatOrDog', 'types' => [$Dog, $Cat], 'resolveType' => function ($value) {
         // not used for validation
         return null;
     }]);
     $Intelligent = new InterfaceType(['name' => 'Intelligent', 'fields' => ['iq' => ['type' => Type::int()]]]);
     $Human = $this->humanType = new ObjectType(['name' => 'Human', 'interfaces' => [$Being, $Intelligent], 'fields' => ['name' => ['args' => ['surname' => ['type' => Type::boolean()]], 'type' => Type::string()], 'pets' => ['type' => Type::listOf($Pet)], 'relatives' => ['type' => function () {
         return Type::listOf($this->humanType);
     }]]]);
     $Alien = new ObjectType(['name' => 'Alien', 'interfaces' => [$Being, $Intelligent], 'fields' => ['iq' => ['type' => Type::int()], 'numEyes' => ['type' => Type::int()]]]);
     $DogOrHuman = new UnionType(['name' => 'DogOrHuman', 'types' => [$Dog, $Human], 'resolveType' => function () {
         // not used for validation
         return null;
     }]);
     $HumanOrAlien = new UnionType(['name' => 'HumanOrAlien', 'types' => [$Human, $Alien], 'resolveType' => function () {
         // not used for validation
         return null;
     }]);
     $ComplexInput = new InputObjectType(['name' => 'ComplexInput', 'fields' => ['requiredField' => ['type' => Type::nonNull(Type::boolean())], 'intField' => ['type' => Type::int()], 'stringField' => ['type' => Type::string()], 'booleanField' => ['type' => Type::boolean()], 'stringListField' => ['type' => Type::listOf(Type::string())]]]);
     $ComplicatedArgs = new ObjectType(['name' => 'ComplicatedArgs', 'fields' => ['intArgField' => ['type' => Type::string(), 'args' => ['intArg' => ['type' => Type::int()]]], 'nonNullIntArgField' => ['type' => Type::string(), 'args' => ['nonNullIntArg' => ['type' => Type::nonNull(Type::int())]]], 'stringArgField' => ['type' => Type::string(), 'args' => ['stringArg' => ['type' => Type::string()]]], 'booleanArgField' => ['type' => Type::string(), 'args' => ['booleanArg' => ['type' => Type::boolean()]]], 'enumArgField' => ['type' => Type::string(), 'args' => ['enumArg' => ['type' => $FurColor]]], 'floatArgField' => ['type' => Type::string(), 'args' => ['floatArg' => ['type' => Type::float()]]], 'idArgField' => ['type' => Type::string(), 'args' => ['idArg' => ['type' => Type::id()]]], 'stringListArgField' => ['type' => Type::string(), 'args' => ['stringListArg' => ['type' => Type::listOf(Type::string())]]], 'complexArgField' => ['type' => Type::string(), 'args' => ['complexArg' => ['type' => $ComplexInput]]], 'multipleReqs' => ['type' => Type::string(), 'args' => ['req1' => ['type' => Type::nonNull(Type::int())], 'req2' => ['type' => Type::nonNull(Type::int())]]], 'multipleOpts' => ['type' => Type::string(), 'args' => ['opt1' => ['type' => Type::int(), 'defaultValue' => 0], 'opt2' => ['type' => Type::int(), 'defaultValue' => 0]]], 'multipleOptAndReq' => ['type' => Type::string(), 'args' => ['req1' => ['type' => Type::nonNull(Type::int())], 'req2' => ['type' => Type::nonNull(Type::int())], 'opt1' => ['type' => Type::int(), 'defaultValue' => 0], 'opt2' => ['type' => Type::int(), 'defaultValue' => 0]]]]]);
     $queryRoot = new ObjectType(['name' => 'QueryRoot', 'fields' => ['human' => ['args' => ['id' => ['type' => Type::id()]], 'type' => $Human], 'alien' => ['type' => $Alien], 'dog' => ['type' => $Dog], 'cat' => ['type' => $Cat], 'pet' => ['type' => $Pet], 'catOrDog' => ['type' => $CatOrDog], 'dogOrHuman' => ['type' => $DogOrHuman], 'humanOrAlien' => ['type' => $HumanOrAlien], 'complicatedArgs' => ['type' => $ComplicatedArgs]]]);
     $defaultSchema = new Schema($queryRoot);
     return $defaultSchema;
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     $NamedType = new InterfaceType(['name' => 'Named', 'fields' => ['name' => ['type' => Type::string()]]]);
     $DogType = new ObjectType(['name' => 'Dog', 'interfaces' => [$NamedType], 'fields' => ['name' => ['type' => Type::string()], 'barks' => ['type' => Type::boolean()]], 'isTypeOf' => function ($value) {
         return $value instanceof Dog;
     }]);
     $CatType = new ObjectType(['name' => 'Cat', 'interfaces' => [$NamedType], 'fields' => ['name' => ['type' => Type::string()], 'meows' => ['type' => Type::boolean()]], 'isTypeOf' => function ($value) {
         return $value instanceof Cat;
     }]);
     $PetType = new UnionType(['name' => 'Pet', 'types' => [$DogType, $CatType], 'resolveType' => function ($value) use($DogType, $CatType) {
         if ($value instanceof Dog) {
             return $DogType;
         }
         if ($value instanceof Cat) {
             return $CatType;
         }
     }]);
     $PersonType = new ObjectType(['name' => 'Person', 'interfaces' => [$NamedType], 'fields' => ['name' => ['type' => Type::string()], 'pets' => ['type' => Type::listOf($PetType)], 'friends' => ['type' => Type::listOf($NamedType)]], 'isTypeOf' => function ($value) {
         return $value instanceof Person;
     }]);
     $this->schema = new Schema($PersonType);
     $this->garfield = new Cat('Garfield', false);
     $this->odie = new Dog('Odie', true);
     $this->liz = new Person('Liz');
     $this->john = new Person('John', [$this->garfield, $this->odie], [$this->liz, $this->odie]);
 }
Ejemplo n.º 3
0
 /**
  * @param string $name
  * @return Type
  */
 public function resolveType($name)
 {
     if (preg_match('#^(.+)\\!$#', $name, $regs)) {
         return Type::nonNull($this->resolveType($regs[1]));
     }
     if (preg_match('#^\\[(.+)\\]$#', $name, $regs)) {
         return Type::listOf($this->resolveType($regs[1]));
     }
     switch ($name) {
         case Type::INT:
             return Type::int();
         case Type::STRING:
             return Type::string();
         case Type::BOOLEAN:
             return Type::boolean();
         case Type::FLOAT:
             return Type::float();
         case Type::ID:
             return Type::id();
         default:
             if (!isset($this->types[$name])) {
                 throw new \InvalidArgumentException(sprintf('Type "%s" is not defined', $name));
             }
             return $this->types[$name];
     }
 }
Ejemplo n.º 4
0
    public function testFieldSelection()
    {
        $image = new ObjectType(['name' => 'Image', 'fields' => ['url' => ['type' => Type::string()], 'width' => ['type' => Type::int()], 'height' => ['type' => Type::int()]]]);
        $article = null;
        $author = new ObjectType(['name' => 'Author', 'fields' => function () use($image, &$article) {
            return ['id' => ['type' => Type::string()], 'name' => ['type' => Type::string()], 'pic' => ['type' => $image, 'args' => ['width' => ['type' => Type::int()], 'height' => ['type' => Type::int()]]], 'recentArticle' => ['type' => $article]];
        }]);
        $reply = new ObjectType(['name' => 'Reply', 'fields' => ['author' => ['type' => $author], 'body' => ['type' => Type::string()]]]);
        $article = new ObjectType(['name' => 'Article', 'fields' => ['id' => ['type' => Type::string()], 'isPublished' => ['type' => Type::boolean()], 'author' => ['type' => $author], 'title' => ['type' => Type::string()], 'body' => ['type' => Type::string()], 'image' => ['type' => $image], 'replies' => ['type' => Type::listOf($reply)]]]);
        $doc = '
      query Test {
        article {
            author {
                name
                pic {
                    url
                    width
                }
            }
            image {
                width
                height
            }
            replies {
                body
                author {
                    id
                    name
                    pic {
                        url
                        width
                    }
                    recentArticle {
                        id
                        title
                        body
                    }
                }
            }
        }
      }
';
        $expectedDefaultSelection = ['author' => true, 'image' => true, 'replies' => true];
        $expectedDeepSelection = ['author' => ['name' => true, 'pic' => ['url' => true, 'width' => true]], 'image' => ['width' => true, 'height' => true], 'replies' => ['body' => true, 'author' => ['id' => true, 'name' => true, 'pic' => ['url' => true, 'width' => true], 'recentArticle' => ['id' => true, 'title' => true, 'body' => true]]]];
        $hasCalled = false;
        $actualDefaultSelection = null;
        $actualDeepSelection = null;
        $blogQuery = new ObjectType(['name' => 'Query', 'fields' => ['article' => ['type' => $article, 'resolve' => function ($value, $args, $context, ResolveInfo $info) use(&$hasCalled, &$actualDefaultSelection, &$actualDeepSelection) {
            $hasCalled = true;
            $actualDefaultSelection = $info->getFieldSelection();
            $actualDeepSelection = $info->getFieldSelection(5);
            return null;
        }]]]);
        $schema = new Schema(['query' => $blogQuery]);
        $result = GraphQL::execute($schema, $doc);
        $this->assertTrue($hasCalled);
        $this->assertEquals(['data' => ['article' => null]], $result);
        $this->assertEquals($expectedDefaultSelection, $actualDefaultSelection);
        $this->assertEquals($expectedDeepSelection, $actualDeepSelection);
    }
Ejemplo n.º 5
0
 /**
  * Fields that exist on every connection.
  *
  * @return array
  */
 protected function baseFields()
 {
     return ['pageInfo' => ['type' => Type::nonNull($this->pageInfoType), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $collection;
     }], 'edges' => ['type' => Type::listOf($this->edgeType), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $this->injectCursor($collection);
     }]];
 }
 /**
  * Fields that exist on every connection.
  *
  * @return array
  */
 protected function baseFields()
 {
     $type = $this->type ?: $this->type();
     return ['pageInfo' => ['type' => Type::nonNull(GraphQL::type('pageInfo')), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $collection;
     }], 'edges' => ['type' => Type::listOf($this->buildEdgeType($this->name, $type)), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $this->injectCursor($collection);
     }]];
 }
Ejemplo n.º 7
0
 /**
  * @describe [T!]!
  */
 public function testHandlesNonNullListOfNonNulls()
 {
     $type = Type::nonNull(Type::listOf(Type::nonNull(Type::int())));
     // Contains values
     $this->check($type, [1, 2], ['data' => ['nest' => ['test' => [1, 2]]]]);
     // Contains null
     $this->check($type, [1, null, 2], ['data' => ['nest' => null], 'errors' => [FormattedError::create('Cannot return null for non-nullable field DataType.test.', [new SourceLocation(1, 10)])]]);
     // Returns null
     $this->check($type, null, ['data' => ['nest' => null], 'errors' => [FormattedError::create('Cannot return null for non-nullable field DataType.test.', [new SourceLocation(1, 10)])]]);
 }
Ejemplo n.º 8
0
 private function withModifiers($types)
 {
     return array_merge(Utils::map($types, function ($type) {
         return Type::listOf($type);
     }), Utils::map($types, function ($type) {
         return Type::nonNull($type);
     }), Utils::map($types, function ($type) {
         return Type::nonNull(Type::listOf($type));
     }));
 }
Ejemplo n.º 9
0
 /**
  * Returns configuration for Plural identifying root field
  *
  * type PluralIdentifyingRootFieldConfig = {
  *       argName: string,
  *       inputType: GraphQLInputType,
  *       outputType: GraphQLOutputType,
  *       resolveSingleInput: (input: any, info: GraphQLResolveInfo) => ?any,
  *       description?: ?string,
  * };
  *
  * @param array $config
  * @return array
  */
 public static function pluralIdentifyingRootField(array $config)
 {
     $inputArgs = [];
     $argName = self::getArrayValue($config, 'argName');
     $inputArgs[$argName] = ['type' => Type::nonNull(Type::listOf(Type::nonNull(self::getArrayValue($config, 'inputType'))))];
     return ['description' => isset($config['description']) ? $config['description'] : null, 'type' => Type::listOf(self::getArrayValue($config, 'outputType')), 'args' => $inputArgs, 'resolve' => function ($obj, $args, $context, ResolveInfo $info) use($argName, $config) {
         $inputs = $args[$argName];
         return array_map(function ($input) use($config, $context, $info) {
             return call_user_func(self::getArrayValue($config, 'resolveSingleInput'), $input, $context, $info);
         }, $inputs);
     }];
 }
Ejemplo n.º 10
0
    public function testExecutesUsingASchema()
    {
        $BlogArticle = null;
        $BlogImage = new ObjectType(['name' => 'Image', 'fields' => ['url' => ['type' => Type::string()], 'width' => ['type' => Type::int()], 'height' => ['type' => Type::int()]]]);
        $BlogAuthor = new ObjectType(['name' => 'Author', 'fields' => ['id' => ['type' => Type::string()], 'name' => ['type' => Type::string()], 'pic' => ['args' => ['width' => ['type' => Type::int()], 'height' => ['type' => Type::int()]], 'type' => $BlogImage, 'resolve' => function ($obj, $args) {
            return $obj['pic']($args['width'], $args['height']);
        }], 'recentArticle' => ['type' => function () use(&$BlogArticle) {
            return $BlogArticle;
        }]]]);
        $BlogArticle = new ObjectType(['name' => 'Article', 'fields' => ['id' => ['type' => Type::nonNull(Type::string())], 'isPublished' => ['type' => Type::boolean()], 'author' => ['type' => $BlogAuthor], 'title' => ['type' => Type::string()], 'body' => ['type' => Type::string()], 'keywords' => ['type' => Type::listOf(Type::string())]]]);
        $BlogQuery = new ObjectType(['name' => 'Query', 'fields' => ['article' => ['type' => $BlogArticle, 'args' => ['id' => ['type' => Type::id()]], 'resolve' => function ($_, $args) {
            return $this->article($args['id']);
        }], 'feed' => ['type' => Type::listOf($BlogArticle), 'resolve' => function () {
            return [$this->article(1), $this->article(2), $this->article(3), $this->article(4), $this->article(5), $this->article(6), $this->article(7), $this->article(8), $this->article(9), $this->article(10)];
        }]]]);
        $BlogSchema = new Schema($BlogQuery);
        $request = '
      {
        feed {
          id,
          title
        },
        article(id: "1") {
          ...articleFields,
          author {
            id,
            name,
            pic(width: 640, height: 480) {
              url,
              width,
              height
            },
            recentArticle {
              ...articleFields,
              keywords
            }
          }
        }
      }

      fragment articleFields on Article {
        id,
        isPublished,
        title,
        body,
        hidden,
        notdefined
      }
    ';
        $expected = ['data' => ['feed' => [['id' => '1', 'title' => 'My Article 1'], ['id' => '2', 'title' => 'My Article 2'], ['id' => '3', 'title' => 'My Article 3'], ['id' => '4', 'title' => 'My Article 4'], ['id' => '5', 'title' => 'My Article 5'], ['id' => '6', 'title' => 'My Article 6'], ['id' => '7', 'title' => 'My Article 7'], ['id' => '8', 'title' => 'My Article 8'], ['id' => '9', 'title' => 'My Article 9'], ['id' => '10', 'title' => 'My Article 10']], 'article' => ['id' => '1', 'isPublished' => true, 'title' => 'My Article 1', 'body' => 'This is a post', 'author' => ['id' => '123', 'name' => 'John Smith', 'pic' => ['url' => 'cdn://123', 'width' => 640, 'height' => 480], 'recentArticle' => ['id' => '1', 'isPublished' => true, 'title' => 'My Article 1', 'body' => 'This is a post', 'keywords' => ['foo', 'bar', '1', 'true', null]]]]]];
        $this->assertEquals($expected, Executor::execute($BlogSchema, Parser::parse($request))->toArray());
    }
Ejemplo n.º 11
0
 public static function buildHumanType()
 {
     if (null !== self::$humanType) {
         return self::$humanType;
     }
     self::$humanType = new ObjectType(['name' => 'Human', 'fields' => function () {
         return ['firstName' => ['type' => Type::nonNull(Type::string())], 'dogs' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(self::buildDogType()))), 'complexity' => function ($childrenComplexity, $args) {
             $complexity = isset($args['name']) ? 1 : 10;
             return $childrenComplexity + $complexity;
         }, 'args' => ['name' => ['type' => Type::string()]]]];
     }]);
     return self::$humanType;
 }
Ejemplo n.º 12
0
 /**
  * Returns a GraphQLObjectType for a connection with the given name,
  * and whose nodes are of the specified type.
  *
  * @return ObjectType
  */
 public static function createConnectionType(array $config)
 {
     if (!array_key_exists('nodeType', $config)) {
         throw new \InvalidArgumentException('Connection config needs to have at least a node definition');
     }
     $nodeType = $config['nodeType'];
     $name = array_key_exists('name', $config) ? $config['name'] : $nodeType->name;
     $connectionFields = array_key_exists('connectionFields', $config) ? $config['connectionFields'] : [];
     $edgeType = array_key_exists('edgeType', $config) ? $config['edgeType'] : null;
     $connectionType = new ObjectType(['name' => $name . 'Connection', 'description' => 'A connection to a list of items.', 'fields' => function () use($edgeType, $connectionFields, $config) {
         return array_merge(['pageInfo' => ['type' => Type::nonNull(self::pageInfoType()), 'description' => 'Information to aid in pagination.'], 'edges' => ['type' => Type::listOf($edgeType ?: self::createEdgeType($config)), 'description' => 'Information to aid in pagination']], self::resolveMaybeThunk($connectionFields));
     }]);
     return $connectionType;
 }
Ejemplo n.º 13
0
    /**
     * @it introspects on input object
     */
    function testIntrospectsOnInputObject()
    {
        $TestInputObject = new InputObjectType(['name' => 'TestInputObject', 'fields' => ['a' => ['type' => Type::string(), 'defaultValue' => 'foo'], 'b' => ['type' => Type::listOf(Type::string())]]]);
        $TestType = new ObjectType(['name' => 'TestType', 'fields' => ['field' => ['type' => Type::string(), 'args' => ['complex' => ['type' => $TestInputObject]], 'resolve' => function ($_, $args) {
            return json_encode($args['complex']);
        }]]]);
        $schema = new Schema(['query' => $TestType]);
        $request = '
          {
            __schema {
              types {
                kind
                name
                inputFields {
                  name
                  type { ...TypeRef }
                  defaultValue
                }
              }
            }
          }

          fragment TypeRef on __Type {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                }
              }
            }
          }
        ';
        $expectedFragment = ['kind' => 'INPUT_OBJECT', 'name' => 'TestInputObject', 'inputFields' => [['name' => 'a', 'type' => ['kind' => 'SCALAR', 'name' => 'String', 'ofType' => null], 'defaultValue' => '"foo"'], ['name' => 'b', 'type' => ['kind' => 'LIST', 'name' => null, 'ofType' => ['kind' => 'SCALAR', 'name' => 'String', 'ofType' => null]], 'defaultValue' => null]]];
        $result = GraphQL::execute($schema, $request);
        $result = $result['data']['__schema']['types'];
        // $this->assertEquals($expectedFragment, $result[1]);
        $this->assertContains($expectedFragment, $result);
    }
Ejemplo n.º 14
0
 /**
  * @see https://github.com/webonyx/graphql-php/issues/59
  */
 public function testSerializesToEmptyObjectVsEmptyArray()
 {
     $iface = null;
     $a = new ObjectType(['name' => 'A', 'fields' => ['id' => Type::id()], 'interfaces' => function () use(&$iface) {
         return [$iface];
     }]);
     $b = new ObjectType(['name' => 'B', 'fields' => ['id' => Type::id()], 'interfaces' => function () use(&$iface) {
         return [$iface];
     }]);
     $iface = new InterfaceType(['name' => 'Iface', 'fields' => ['id' => Type::id()], 'resolveType' => function ($v) use($a, $b) {
         return $v['type'] === 'A' ? $a : $b;
     }]);
     $schema = new Schema(['query' => new ObjectType(['name' => 'Query', 'fields' => ['ab' => Type::listOf($iface)]]), 'types' => [$a, $b]]);
     $data = ['ab' => [['id' => 1, 'type' => 'A'], ['id' => 2, 'type' => 'A'], ['id' => 3, 'type' => 'B'], ['id' => 4, 'type' => 'B']]];
     $query = Parser::parse('
         {
             ab {
                 ... on A{
                     id
                 }
             }
         }
     ');
     $result = Executor::execute($schema, $query, $data, null);
     $this->assertEquals(['data' => ['ab' => [['id' => '1'], ['id' => '2'], new \stdClass(), new \stdClass()]]], $result->toArray());
 }
Ejemplo n.º 15
0
 static function build()
 {
     $typeEnum = new EnumType(["name" => "Type", "description" => "The type of entity", "values" => ["user" => ["value" => "user"], "group" => ["value" => "group"], "object" => ["value" => "object"]]]);
     $statusEnum = new EnumType(["name" => "Status", "description" => "The status of the entity", "values" => ["ok" => ["value" => "ok"], "access_denied" => ["value" => "access_denied"], "not_found" => ["value" => "not_found"]]]);
     $voteDirectionEnum = new EnumType(["name" => "VoteType", "description" => "The type of vote", "values" => ["up" => ["value" => "up"], "down" => ["value" => "down"]]]);
     $entityInterface = new InterfaceType(["name" => "Entity", "fields" => ["guid" => ["type" => Type::nonNull(Type::string())], "status" => ["type" => Type::nonNull($statusEnum)]], "resolveType" => function ($object) use(&$userType, &$objectType, &$groupType) {
         switch ($object["type"]) {
             case "user":
                 return $userType;
             case "object":
                 return $objectType;
             case "group":
                 return $groupType;
         }
     }]);
     $accessIdType = new ObjectType(["name" => "AccessId", "fields" => ["id" => ["type" => Type::nonNull(Type::int())], "description" => ["type" => Type::nonNull(Type::string())]]]);
     $userType = new ObjectType(["name" => "User", "interfaces" => [$entityInterface], "fields" => ["guid" => ["type" => Type::nonNull(Type::string())], "status" => ["type" => Type::nonNull($statusEnum)], "name" => ["type" => Type::string()], "icon" => ["type" => Type::string()], "url" => ["type" => Type::string()]]]);
     $groupType = new ObjectType(["name" => "Group", "interfaces" => [$entityInterface], "fields" => ["guid" => ["type" => Type::nonNull(Type::string())], "status" => ["type" => Type::nonNull($statusEnum)], "name" => ["type" => Type::string()], "icon" => ["type" => Type::string()], "canEdit" => ["type" => Type::boolean()], "isClosed" => ["type" => Type::boolean()], "canJoin" => ["type" => Type::boolean()], "defaultAccessId" => ["type" => Type::int()]]]);
     $objectType = new ObjectType(["name" => "Object", "interfaces" => [$entityInterface], "fields" => ["guid" => ["type" => Type::nonNull(Type::string())], "status" => ["type" => Type::nonNull($statusEnum)], "title" => ["type" => Type::string()], "subtype" => ["type" => Type::string()], "description" => ["type" => Type::string()], "url" => ["type" => Type::string()], "tags" => ["type" => Type::listOf(Type::string())], "timeCreated" => ["type" => Type::string()], "timeUpdated" => ["type" => Type::string()], "canEdit" => ["type" => Type::boolean()], "canComment" => ["type" => Type::boolean()], "accessId" => ["type" => Type::int()], "isBookmarked" => ["type" => Type::boolean(), "resolve" => function ($object) {
         return Resolver::isBookmarked($object);
     }], "votes" => ["type" => Type::int(), "resolve" => function ($object) {
         return Resolver::countVotes($object);
     }], "owner" => ["type" => $userType, "resolve" => function ($object) {
         return Resolver::getUser($object["ownerGuid"]);
     }], "comments" => ["type" => function () use(&$objectType) {
         return Type::listOf($objectType);
     }, "resolve" => function ($object) {
         return Resolver::getComments($object);
     }]]]);
     $searchListType = new ObjectType(["name" => "Search", "fields" => ["total" => ["type" => Type::nonNull(Type::int())], "results" => ["type" => Type::listOf($entityInterface)]]]);
     $entityListType = new ObjectType(["name" => "EntityList", "fields" => ["total" => ["type" => Type::nonNull(Type::int())], "canWrite" => ["type" => Type::nonNull(Type::boolean())], "entities" => ["type" => Type::listOf($entityInterface)]]]);
     $viewerType = new ObjectType(["name" => "Viewer", "description" => "The current site viewer", "fields" => ["guid" => ["type" => Type::nonNull(Type::string())], "loggedIn" => ["type" => Type::nonNull(Type::boolean())], "username" => ["type" => Type::string()], "name" => ["type" => Type::string()], "icon" => ["type" => Type::string()], "url" => ["type" => Type::string()], "bookmarks" => ["type" => $entityListType, "args" => ["offset" => ["type" => Type::int()], "limit" => ["type" => Type::int()]], "resolve" => "Pleio\\Resolver::getBookmarks"]]]);
     $menuItemType = new ObjectType(["name" => "MenuItem", "fields" => ["guid" => ["type" => Type::nonNull(Type::string())], "title" => ["type" => Type::nonNull(Type::string())], "link" => ["type" => Type::nonNull(Type::string())], "js" => ["type" => Type::nonNull(Type::boolean())]]]);
     $siteType = new ObjectType(["name" => "Site", "description" => "The current site", "fields" => ["id" => ["type" => Type::nonNull(Type::string())], "title" => ["type" => Type::nonNull(Type::string())], "menu" => ["type" => Type::listOf($menuItemType)], "accessIds" => ["type" => Type::listOf($accessIdType)], "defaultAccessId" => ["type" => Type::nonNull(Type::int())]]]);
     $queryType = new ObjectType(["name" => "Query", "fields" => ["viewer" => ["type" => $viewerType, "resolve" => "Pleio\\Resolver::getViewer"], "entity" => ["type" => $entityInterface, "args" => ["guid" => ["type" => Type::nonNull(Type::string())]], "resolve" => "Pleio\\Resolver::getEntity"], "search" => ["type" => $searchListType, "args" => ["q" => ["type" => Type::nonNull(Type::string())], "offset" => ["type" => Type::int()], "limit" => ["type" => Type::int()]], "resolve" => "Pleio\\Resolver::search"], "entities" => ["type" => $entityListType, "args" => ["offset" => ["type" => Type::int()], "limit" => ["type" => Type::int()], "type" => ["type" => $typeEnum], "subtype" => ["type" => Type::string()], "containerGuid" => ["type" => Type::int()], "tags" => ["type" => Type::listOf(Type::string())]], "resolve" => "Pleio\\Resolver::getEntities"], "site" => ["type" => $siteType, "resolve" => "Pleio\\Resolver::getSite"]]]);
     $loginMutation = Relay::mutationWithClientMutationId(["name" => "login", "inputFields" => ["username" => ["type" => Type::nonNull(Type::string())], "password" => ["type" => Type::nonNull(Type::string())], "rememberMe" => ["type" => Type::boolean()]], "outputFields" => ["viewer" => ["type" => $viewerType, "resolve" => "Pleio\\Resolver::getViewer"]], "mutateAndGetPayload" => "Pleio\\Mutations::login"]);
     $logoutMutation = Relay::mutationWithClientMutationId(["name" => "logout", "inputFields" => [], "outputFields" => ["viewer" => ["type" => $viewerType, "resolve" => "Pleio\\Resolver::getViewer"]], "mutateAndGetPayload" => "Pleio\\Mutations::logout"]);
     $registerMutation = Relay::mutationWithClientMutationId(["name" => "register", "inputFields" => ["name" => ["type" => Type::nonNull(Type::string())], "email" => ["type" => Type::nonNull(Type::string())], "password" => ["type" => Type::nonNull(Type::string())], "newsletter" => ["type" => Type::boolean()], "terms" => ["type" => Type::boolean()]], "outputFields" => ["viewer" => ["type" => $viewerType, "resolve" => "Pleio\\Resolver::getViewer"]], "mutateAndGetPayload" => "Pleio\\Mutations::register"]);
     $forgotPasswordMutation = Relay::mutationWithClientMutationId(["name" => "forgotPassword", "inputFields" => ["username" => ["type" => Type::nonNull(Type::string())]], "outputFields" => ["status" => ["type" => Type::nonNull($statusEnum), "resolve" => function ($return) {
         return $return["status"];
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::forgotPassword"]);
     $forgotPasswordConfirmMutation = Relay::mutationWithClientMutationId(["name" => "forgotPasswordConfirm", "inputFields" => ["userGuid" => ["type" => Type::nonNull(Type::string())], "code" => ["type" => Type::nonNull(Type::string())]], "outputFields" => ["status" => ["type" => Type::nonNull($statusEnum), "resolve" => function ($return) {
         return $return["status"];
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::forgotPasswordConfirm"]);
     $subscribeNewsletterMutation = Relay::mutationWithClientMutationId(["name" => "subscribeNewsletter", "inputFields" => ["email" => ["type" => Type::nonNull(Type::string())]], "outputFields" => ["viewer" => ["type" => $viewerType, "resolve" => "Pleio\\Resolver::getViewer"]], "mutateAndGetPayload" => "Pleio\\Mutations::subscribeNewsletter"]);
     $addEntityMutation = Relay::mutationWithClientMutationId(["name" => "addEntity", "inputFields" => ["type" => ["type" => Type::nonNull($typeEnum)], "subtype" => ["type" => Type::nonNull(Type::string())], "title" => ["type" => Type::string()], "description" => ["type" => Type::nonNull(Type::string())], "containerGuid" => ["type" => Type::int()], "accessId" => ["type" => Type::int()], "tags" => ["type" => Type::listOf(Type::string())]], "outputFields" => ["entity" => ["type" => $entityInterface, "resolve" => function ($entity) {
         return Resolver::getEntity(null, $entity, null);
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::addEntity"]);
     $editEntityMutation = Relay::mutationWithClientMutationId(["name" => "editEntity", "inputFields" => ["guid" => ["type" => Type::nonNull(Type::string())], "title" => ["type" => Type::string()], "description" => ["type" => Type::nonNull(Type::string())], "accessId" => ["type" => Type::int()], "tags" => ["type" => Type::listOf(Type::string())]], "outputFields" => ["entity" => ["type" => $entityInterface, "resolve" => function ($entity) {
         return Resolver::getEntity(null, $entity, null);
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::editEntity"]);
     $deleteEntityMutation = Relay::mutationWithClientMutationId(["name" => "deleteEntity", "inputFields" => ["guid" => ["type" => Type::nonNull(Type::string())]], "outputFields" => ["entity" => ["type" => $entityInterface, "resolve" => function ($entity) {
         return Resolver::getEntity(null, $entity, null);
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::deleteEntity"]);
     $bookmarkMutation = Relay::mutationWithClientMutationId(["name" => "bookmark", "inputFields" => ["guid" => ["type" => Type::nonNull(Type::string()), "description" => "The guid of the entity to bookmark."], "isAdding" => ["type" => Type::nonNull(Type::boolean()), "description" => "True when adding, false when removing."]], "outputFields" => ["object" => ["type" => Type::nonNull($objectType), "resolve" => function ($entity) {
         return Resolver::getEntity(null, $entity, null);
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::bookmark"]);
     $voteMutation = Relay::mutationWithClientMutationId(["name" => "vote", "inputFields" => ["guid" => ["type" => Type::nonNull(Type::string()), "description" => "The guid of the entity to bookmark."], "direction" => ["type" => Type::nonNull($voteDirectionEnum)]], "outputFields" => ["object" => ["type" => Type::nonNull($objectType), "resolve" => function ($entity) {
         return Resolver::getEntity(null, $entity, null);
     }]], "mutateAndGetPayload" => "Pleio\\Mutations::vote"]);
     $mutationType = new ObjectType(["name" => "Mutation", "fields" => ["login" => $loginMutation, "logout" => $logoutMutation, "register" => $registerMutation, "forgotPassword" => $forgotPasswordMutation, "forgotPasswordConfirm" => $forgotPasswordConfirmMutation, "addEntity" => $addEntityMutation, "editEntity" => $editEntityMutation, "deleteEntity" => $deleteEntityMutation, "subscribeNewsletter" => $subscribeNewsletterMutation, "bookmark" => $bookmarkMutation, "vote" => $voteMutation]]);
     $schema = new Schema($queryType, $mutationType);
     return $schema;
 }
Ejemplo n.º 16
0
 public static function build()
 {
     /**
      * The original trilogy consists of three movies.
      *
      * This implements the following type system shorthand:
      *   enum Episode { NEWHOPE, EMPIRE, JEDI }
      */
     $episodeEnum = new EnumType(['name' => 'Episode', 'description' => 'One of the films in the Star Wars Trilogy', 'values' => ['NEWHOPE' => ['value' => 4, 'description' => 'Released in 1977.'], 'EMPIRE' => ['value' => 5, 'description' => 'Released in 1980.'], 'JEDI' => ['value' => 6, 'description' => 'Released in 1983.']]]);
     $humanType = null;
     $droidType = null;
     /**
      * Characters in the Star Wars trilogy are either humans or droids.
      *
      * This implements the following type system shorthand:
      *   interface Character {
      *     id: String!
      *     name: String
      *     friends: [Character]
      *     appearsIn: [Episode]
      *   }
      */
     $characterInterface = new InterfaceType(['name' => 'Character', 'description' => 'A character in the Star Wars Trilogy', 'fields' => function () use(&$characterInterface, $episodeEnum) {
         return ['id' => ['type' => Type::nonNull(Type::string()), 'description' => 'The id of the character.'], 'name' => ['type' => Type::string(), 'description' => 'The name of the character.'], 'friends' => ['type' => Type::listOf($characterInterface), 'description' => 'The friends of the character, or an empty list if they have none.'], 'appearsIn' => ['type' => Type::listOf($episodeEnum), 'description' => 'Which movies they appear in.'], 'secretBackstory' => ['type' => Type::string(), 'description' => 'All secrets about their past.']];
     }, 'resolveType' => function ($obj) use(&$humanType, &$droidType) {
         return StarWarsData::getHuman($obj['id']) ? $humanType : $droidType;
     }]);
     /**
      * We define our human type, which implements the character interface.
      *
      * This implements the following type system shorthand:
      *   type Human : Character {
      *     id: String!
      *     name: String
      *     friends: [Character]
      *     appearsIn: [Episode]
      *     secretBackstory: String
      *   }
      */
     $humanType = new ObjectType(['name' => 'Human', 'description' => 'A humanoid creature in the Star Wars universe.', 'fields' => ['id' => ['type' => new NonNull(Type::string()), 'description' => 'The id of the human.'], 'name' => ['type' => Type::string(), 'description' => 'The name of the human.'], 'friends' => ['type' => Type::listOf($characterInterface), 'description' => 'The friends of the human, or an empty list if they have none.', 'resolve' => function ($human, $args, $context, ResolveInfo $info) {
         $fieldSelection = $info->getFieldSelection();
         $fieldSelection['id'] = true;
         $friends = array_map(function ($friend) use($fieldSelection) {
             return array_intersect_key($friend, $fieldSelection);
         }, StarWarsData::getFriends($human));
         return $friends;
     }], 'appearsIn' => ['type' => Type::listOf($episodeEnum), 'description' => 'Which movies they appear in.'], 'homePlanet' => ['type' => Type::string(), 'description' => 'The home planet of the human, or null if unknown.'], 'secretBackstory' => ['type' => Type::string(), 'description' => 'Where are they from and how they came to be who they are.', 'resolve' => function () {
         // This is to demonstrate error reporting
         throw new \Exception('secretBackstory is secret.');
     }]], 'interfaces' => [$characterInterface]]);
     /**
      * The other type of character in Star Wars is a droid.
      *
      * This implements the following type system shorthand:
      *   type Droid : Character {
      *     id: String!
      *     name: String
      *     friends: [Character]
      *     appearsIn: [Episode]
      *     secretBackstory: String
      *     primaryFunction: String
      *   }
      */
     $droidType = new ObjectType(['name' => 'Droid', 'description' => 'A mechanical creature in the Star Wars universe.', 'fields' => ['id' => ['type' => Type::nonNull(Type::string()), 'description' => 'The id of the droid.'], 'name' => ['type' => Type::string(), 'description' => 'The name of the droid.'], 'friends' => ['type' => Type::listOf($characterInterface), 'description' => 'The friends of the droid, or an empty list if they have none.', 'resolve' => function ($droid) {
         return StarWarsData::getFriends($droid);
     }], 'appearsIn' => ['type' => Type::listOf($episodeEnum), 'description' => 'Which movies they appear in.'], 'secretBackstory' => ['type' => Type::string(), 'description' => 'Construction date and the name of the designer.', 'resolve' => function () {
         // This is to demonstrate error reporting
         throw new \Exception('secretBackstory is secret.');
     }], 'primaryFunction' => ['type' => Type::string(), 'description' => 'The primary function of the droid.']], 'interfaces' => [$characterInterface]]);
     /**
      * This is the type that will be the root of our query, and the
      * entry point into our schema. It gives us the ability to fetch
      * objects by their IDs, as well as to fetch the undisputed hero
      * of the Star Wars trilogy, R2-D2, directly.
      *
      * This implements the following type system shorthand:
      *   type Query {
      *     hero(episode: Episode): Character
      *     human(id: String!): Human
      *     droid(id: String!): Droid
      *   }
      *
      */
     $queryType = new ObjectType(['name' => 'Query', 'fields' => ['hero' => ['type' => $characterInterface, 'args' => ['episode' => ['description' => 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.', 'type' => $episodeEnum]], 'resolve' => function ($root, $args) {
         return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null);
     }], 'human' => ['type' => $humanType, 'args' => ['id' => ['name' => 'id', 'description' => 'id of the human', 'type' => Type::nonNull(Type::string())]], 'resolve' => function ($root, $args) {
         $humans = StarWarsData::humans();
         return isset($humans[$args['id']]) ? $humans[$args['id']] : null;
     }], 'droid' => ['type' => $droidType, 'args' => ['id' => ['name' => 'id', 'description' => 'id of the droid', 'type' => Type::nonNull(Type::string())]], 'resolve' => function ($root, $args) {
         $droids = StarWarsData::droids();
         return isset($droids[$args['id']]) ? $droids[$args['id']] : null;
     }]]]);
     return new Schema(['query' => $queryType]);
 }
Ejemplo n.º 17
0
 public static function build()
 {
     $ValueType = new ObjectType(['name' => 'Value', 'description' => 'Value', 'fields' => ['id' => ['type' => new NonNull(Type::int()), 'description' => 'The id of the value.'], 'atri_id' => ['type' => Type::int(), 'description' => 'The attribute of the value.'], 'atri_name' => ['type' => Type::string(), 'description' => 'Attribute name'], 'atri_tag' => ['type' => Type::string(), 'description' => 'Attribute tag'], 'atri_type' => ['type' => Type::string(), 'description' => 'Attribute Type'], 'atri_language' => ['type' => Type::string(), 'description' => 'Attribute language'], 'inst_id' => ['type' => Type::int(), 'description' => 'The instance_id in which the value is contained.'], 'text_val' => ['type' => Type::string(), 'description' => 'The text_val of the value.'], 'num_val' => ['type' => Type::string(), 'description' => 'The num_val of the value.'], 'date_val' => ['type' => Type::string(), 'description' => 'The date_val of the value.'], 'img_info' => ['type' => Type::string(), 'description' => 'Image info of the value, only valid for images.'], 'is_detail' => ['type' => Type::string(), 'description' => 'Is detail? Y or N'], 'cache_time' => ['type' => Type::int(), 'description' => 'Cache Time'], 'cache_status' => ['type' => Type::string(), 'description' => 'Cache status (hit|miss)']]]);
     $RelationType = new ObjectType(['name' => 'Relation', 'description' => 'Relation Instance', 'fields' => ['id' => ['type' => new NonNull(Type::int()), 'description' => 'The id of the relation.'], 'tag' => ['type' => new NonNull(Type::string()), 'description' => 'Relation tag'], 'language' => ['type' => Type::string(), 'description' => 'Relation language'], 'direction' => ['type' => new NonNull(Type::string()), 'description' => 'Relation direction'], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'inst_id' => ['type' => Type::int(), 'description' => 'initial inst_id, the driver instance'], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format'], 'instances' => ['type' => function () use(&$InstanceType) {
         return Type::listOf($InstanceType);
     }, 'description' => 'The related children or parents of this relation.', 'args' => ['filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($relation, $args) {
         //echo "ARGS ABANS DEL GETRELATED\n";
         //print_r($relation['args']);
         //echo "PARENT ARGS ABANS DEL GETRELATED\n";
         $insts = EditoraData::getRelated($relation['direction'], $relation['id'], $relation['inst_id'], $relation['args'], null);
         //echo "Instancies despres del GetRelated\n";
         //print_r($insts);
         if ($insts && !empty($insts[0])) {
             return $insts;
         }
         return null;
     }]]]);
     $InstanceListType = new ObjectType(['name' => 'instance_list', 'description' => 'Instance List', 'fields' => ['ids' => ['type' => new NonNull(Type::string()), 'description' => 'The ids of the instances.'], 'language' => ['type' => Type::string(), 'description' => 'Class language'], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format'], 'instances' => ['type' => function () use(&$InstanceType) {
         return Type::listOf($InstanceType);
     }, 'description' => 'The instances list', 'args' => ['filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance_list, $args) {
         //echo "instance resolve\n";
         //print_r($class);
         $insts = EditoraData::getInstancesList($args, $instance_list['args']);
         //echo "attrs\n";
         //print_r($insts);
         if ($insts) {
             return $insts;
         }
         return null;
     }]]]);
     $ClassType = new ObjectType(['name' => 'class', 'description' => 'Class', 'fields' => ['class_id' => ['type' => new NonNull(Type::int()), 'description' => 'The id of the class.'], 'tag' => ['type' => new NonNull(Type::string()), 'description' => 'Class tag'], 'language' => ['type' => Type::string(), 'description' => 'Class language'], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format'], 'instances' => ['type' => function () use(&$InstanceType) {
         return Type::listOf($InstanceType);
     }, 'description' => 'The instances of this class.', 'args' => ['filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($class, $args) {
         //echo "instance resolve\n";
         //print_r($class);
         $insts = EditoraData::getInstacesOfClass($class['class_id'], $class, $args, $class['args']);
         //echo "attrs\n";
         //print_r($insts);
         if ($insts) {
             return $insts;
         }
         return null;
     }]]]);
     $SearchType = new ObjectType(['name' => 'search', 'description' => 'Search', 'fields' => ['query' => ['type' => new NonNull(Type::string()), 'description' => 'search query'], 'class_id' => ['type' => Type::int(), 'description' => 'The id of the class.'], 'tag' => ['type' => Type::string(), 'description' => 'class tag'], 'language' => ['type' => Type::string(), 'description' => 'Relation language'], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format'], 'instances' => ['type' => function () use(&$InstanceType) {
         return Type::listOf($InstanceType);
     }, 'description' => 'The instances of this class.', 'args' => ['filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($search, $args) {
         //echo "instance resolve\n";
         //print_r($search);
         $insts = EditoraData::getInstacesOfSearch($search['query'], $search, $args, $search['args']);
         //echo "attrs\n";
         //print_r($insts);
         if ($insts) {
             return $insts;
         }
         return null;
     }]]]);
     $InstanceType = new ObjectType(['name' => 'Instance', 'description' => 'Instance of any class', 'fields' => ['id' => ['type' => new NonNull(Type::int()), 'description' => 'The id of instance.'], 'class_id' => ['type' => Type::int(), 'description' => 'The class_id of instance.'], 'class_name' => ['type' => Type::string(), 'description' => 'The class_name of instance.'], 'class_tag' => ['type' => Type::string(), 'description' => 'The class_tag of instance.'], 'key_fields' => ['type' => Type::string(), 'description' => 'The internal name of the instance.'], 'nom_intern' => ['type' => Type::string(), 'description' => 'The internal name of the instance.'], 'status' => ['type' => Type::string(), 'description' => 'The status of the instance.'], 'publishing_begins' => ['type' => Type::string(), 'description' => 'The publishing start of the instance.'], 'publishing_ends' => ['type' => Type::string(), 'description' => 'The publishing start of the instance.'], 'creation_date' => ['type' => Type::string(), 'description' => 'The creation of the instance.'], 'update_date' => ['type' => Type::string(), 'description' => 'The update of the instance.'], 'update_timestamp' => ['type' => Type::int(), 'description' => 'The update of the instance in unix timestamp.'], 'nice_url' => ['type' => Type::string(), 'description' => 'The niceurl of the instance.'], 'link' => ['type' => Type::string(), 'description' => 'The link to the the instance.'], 'all_values' => ['type' => Type::listOf($ValueType), 'description' => 'The attributes of the instance.', 'args' => ['filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()]], 'resolve' => function ($instance, $args) {
         //print_r($args);
         //echo "Instance in EditoraSchema vaig a treure els values\n";
         //print_r($instance);
         if (isset($instance) && isset($instance['id']) && isset($instance['update_timestamp']) && isset($instance['args'])) {
             $attrs = EditoraData::getValues($instance['id'], $instance['update_timestamp'], $args, $instance['args']);
             //print_r($attrs);
             if ($attrs) {
                 return $attrs;
             }
         }
         return null;
     }], 'relation1' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         //echo "aqui tinc aquests args\n";
         //print_r($args);
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation2' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation3' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation4' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation5' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation6' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation7' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation8' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation9' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation10' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation11' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation12' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation13' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation14' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }], 'relation15' => ['type' => Type::listOf($RelationType), 'description' => 'The children of the instance.', 'args' => ['tag' => ['name' => 'tag', 'description' => 'tag of the relation', 'type' => new NonNull(Type::String())], 'alias' => ['name' => 'alias', 'description' => 'alias of the relation', 'type' => Type::String()], 'limit' => ['name' => 'limit', 'description' => 'number of children to get, default 1000', 'type' => Type::Int()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'filter' => ['name' => 'filter', 'description' => 'filter some fields all|detail|resume default all', 'type' => Type::String()], 'direction' => ['name' => 'direction', 'description' => 'force a direction, by default is children, use parents if you want to override', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($instance, $args) {
         if (isset($instance) && isset($instance['id']) && isset($instance['class_id']) && isset($instance['args'])) {
             $related = EditoraData::getRelations($instance['id'], $instance['class_id'], $args, $instance['args']);
             //print_r($related);
             if ($related) {
                 return $related;
             }
         }
         return null;
     }]]]);
     $queryType = new ObjectType(['name' => 'Query', 'fields' => ['instance' => ['type' => $InstanceType, 'args' => ['id' => ['name' => 'id', 'description' => 'id of the Instance', 'type' => Type::Int()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($root, $args) {
         $instance = EditoraData::getInstance($args);
         if ($instance) {
             return $instance;
         }
         return null;
         //return isset($instance[$args['id']]) ? $instance[$args['id']] : null;
     }], 'class' => ['type' => $ClassType, 'args' => ['class_id' => ['name' => 'class_id', 'description' => 'id of the Class', 'type' => Type::Int()], 'tag' => ['name' => 'tag', 'description' => 'tag of the Class', 'type' => Type::String()], 'order' => ['name' => 'order', 'description' => 'order class instances by order criteria, update_date|publishing_begins|inst_id|key_fields default publishing_begins', 'type' => Type::String()], 'order_direction' => ['name' => 'order_direction', 'description' => 'direction of the order by clause, desc|asc defaults to asc', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($root, $args) {
         $class = EditoraData::getClass($args);
         //echo "Al query type !!!$class!!!\n";
         //print_r($class);
         //												die;
         if ($class && !empty($class)) {
             return $class;
         }
         return null;
         //return isset($instance[$args['id']]) ? $instance[$args['id']] : null;
     }], 'instances_list' => ['type' => $InstanceListType, 'args' => ['ids' => ['name' => 'ids', 'description' => 'list of ids in format (1,2,3...)', 'type' => Type::String()], 'order' => ['name' => 'order', 'description' => 'order class instances by order criteria, update_date|publishing_begins|inst_id|key_fields default publishing_begins', 'type' => Type::String()], 'order_direction' => ['name' => 'order_direction', 'description' => 'direction of the order by clause, desc|asc defaults to asc', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($root, $args) {
         $instance_list = EditoraData::getInstanceList($args);
         //echo "Al query type\n";
         //print_r($instance_list);
         //die;
         if ($instance_list) {
             return $instance_list;
         }
         return null;
         //return isset($instance[$args['id']]) ? $instance[$args['id']] : null;
     }], 'search' => ['type' => $SearchType, 'args' => ['query' => ['name' => 'query', 'description' => 'Query string for search', 'type' => Type::String()], 'class_id' => ['name' => 'class_id', 'description' => 'Optional id of the Class', 'type' => Type::Int()], 'tag' => ['name' => 'tag', 'description' => 'Optional tag of the class', 'type' => Type::String()], 'lang' => ['name' => 'lang', 'description' => 'Language of the extraction', 'type' => Type::String()], 'limit' => ['type' => Type::int(), 'description' => 'limit of extraction'], 'debug' => ['name' => 'debug', 'description' => 'Sets the debug flag if true', 'type' => Type::boolean()], 'preview' => ['type' => Type::boolean(), 'description' => 'Preview true or false, default false'], 'preview_date' => ['type' => Type::string(), 'description' => 'Preview date in %Y%m%d%H%i%S format']], 'resolve' => function ($root, $args) {
         $search = EditoraData::getSearch($args);
         //echo "Al query type\n";
         //print_r($search);
         //die;
         if ($search) {
             return $search;
         }
         return null;
         //return isset($instance[$args['id']]) ? $instance[$args['id']] : null;
     }]]]);
     return new Schema(['query' => $queryType, 'mutation' => null, 'types' => null]);
 }
 private function getTestSchema()
 {
     $StringBox = new ObjectType(['name' => 'StringBox', 'fields' => ['scalar' => ['type' => Type::string()]]]);
     $IntBox = new ObjectType(['name' => 'IntBox', 'fields' => ['scalar' => ['type' => Type::int()]]]);
     $NonNullStringBox1 = new ObjectType(['name' => 'NonNullStringBox1', 'fields' => ['scalar' => ['type' => Type::nonNull(Type::string())]]]);
     $NonNullStringBox2 = new ObjectType(['name' => 'NonNullStringBox2', 'fields' => ['scalar' => ['type' => Type::nonNull(Type::string())]]]);
     $BoxUnion = new UnionType(['name' => 'BoxUnion', 'resolveType' => function () use($StringBox) {
         return $StringBox;
     }, 'types' => [$StringBox, $IntBox, $NonNullStringBox1, $NonNullStringBox2]]);
     $Connection = new ObjectType(['name' => 'Connection', 'fields' => ['edges' => ['type' => Type::listOf(new ObjectType(['name' => 'Edge', 'fields' => ['node' => ['type' => new ObjectType(['name' => 'Node', 'fields' => ['id' => ['type' => Type::id()], 'name' => ['type' => Type::string()]]])]]]))]]]);
     $schema = new Schema(new ObjectType(['name' => 'QueryRoot', 'fields' => ['boxUnion' => ['type' => $BoxUnion], 'connection' => ['type' => $Connection]]]));
     return $schema;
 }
Ejemplo n.º 19
0
 public function schema()
 {
     $ComplexScalarType = ComplexScalar::create();
     $TestInputObject = new InputObjectType(['name' => 'TestInputObject', 'fields' => ['a' => ['type' => Type::string()], 'b' => ['type' => Type::listOf(Type::string())], 'c' => ['type' => Type::nonNull(Type::string())], 'd' => ['type' => $ComplexScalarType]]]);
     $TestNestedInputObject = new InputObjectType(['name' => 'TestNestedInputObject', 'fields' => ['na' => ['type' => Type::nonNull($TestInputObject)], 'nb' => ['type' => Type::nonNull(Type::string())]]]);
     $TestType = new ObjectType(['name' => 'TestType', 'fields' => ['fieldWithObjectInput' => ['type' => Type::string(), 'args' => ['input' => ['type' => $TestInputObject]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'fieldWithNullableStringInput' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::string()]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'fieldWithNonNullableStringInput' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::nonNull(Type::string())]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'fieldWithDefaultArgumentValue' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::string(), 'defaultValue' => 'Hello World']], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'fieldWithNestedInputObject' => ['type' => Type::string(), 'args' => ['input' => ['type' => $TestNestedInputObject, 'defaultValue' => 'Hello World']], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'list' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::listOf(Type::string())]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'nnList' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::nonNull(Type::listOf(Type::string()))]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'listNN' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::listOf(Type::nonNull(Type::string()))]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }], 'nnListNN' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(Type::string())))]], 'resolve' => function ($_, $args) {
         return isset($args['input']) ? json_encode($args['input']) : null;
     }]]]);
     $schema = new Schema(['query' => $TestType]);
     return $schema;
 }
Ejemplo n.º 20
0
 public function testAllowsRecursiveDefinitions()
 {
     // See https://github.com/webonyx/graphql-php/issues/16
     $node = new InterfaceType(['name' => 'Node', 'fields' => ['id' => ['type' => Type::nonNull(Type::id())]]]);
     $blog = null;
     $called = false;
     $user = new ObjectType(['name' => 'User', 'fields' => function () use(&$blog, &$called) {
         $this->assertNotNull($blog, 'Blog type is expected to be defined at this point, but it is null');
         $called = true;
         return ['id' => ['type' => Type::nonNull(Type::id())], 'blogs' => ['type' => Type::nonNull(Type::listOf(Type::nonNull($blog)))]];
     }, 'interfaces' => function () use($node) {
         return [$node];
     }]);
     $blog = new ObjectType(['name' => 'Blog', 'fields' => function () use($user) {
         return ['id' => ['type' => Type::nonNull(Type::id())], 'owner' => ['type' => Type::nonNull($user)]];
     }, 'interfaces' => function () use($node) {
         return [$node];
     }]);
     $schema = new Schema(new ObjectType(['name' => 'Query', 'fields' => ['node' => ['type' => $node]]]));
     $this->assertTrue($called);
     $this->assertEquals([$node], $blog->getInterfaces());
     $this->assertEquals([$node], $user->getInterfaces());
     $this->assertNotNull($user->getField('blogs'));
     $this->assertSame($blog, $user->getField('blogs')->getType()->getWrappedType(true));
     $this->assertNotNull($blog->getField('owner'));
     $this->assertSame($user, $blog->getField('owner')->getType()->getWrappedType(true));
 }
Ejemplo n.º 21
0
 /**
  * @it converts list singletons
  */
 public function testConvertsListSingletons()
 {
     $this->assertEquals(new StringValue(['value' => 'FOO']), AST::astFromValue('FOO', Type::listOf(Type::string())));
 }
Ejemplo n.º 22
0
 public function testResolvedValueIsMemoized()
 {
     $doc = '
   query Q {
     a {
       b {
         c
         d
       }
     }
   }
   ';
     $memoizedValue = new \ArrayObject(['b' => 'id1']);
     $A = null;
     $Test = new ObjectType(['name' => 'Test', 'fields' => ['a' => ['type' => function () use(&$A) {
         return Type::listOf($A);
     }, 'resolve' => function () use($memoizedValue) {
         return [$memoizedValue, new \ArrayObject(['b' => 'id2']), $memoizedValue, new \ArrayObject(['b' => 'id2'])];
     }]]]);
     $callCounts = ['id1' => 0, 'id2' => 0];
     $A = new ObjectType(['name' => 'A', 'fields' => ['b' => ['type' => new ObjectType(['name' => 'B', 'fields' => ['c' => ['type' => Type::string()], 'd' => ['type' => Type::string()]]]), 'resolve' => function ($value) use(&$callCounts) {
         $callCounts[$value['b']]++;
         switch ($value['b']) {
             case 'id1':
                 return ['c' => 'c1', 'd' => 'd1'];
             case 'id2':
                 return ['c' => 'c2', 'd' => 'd2'];
         }
     }]]]);
     // Test that value resolved once is memoized for same query field
     $schema = new Schema($Test);
     $query = Parser::parse($doc);
     $result = Executor::execute($schema, $query);
     $expected = ['data' => ['a' => [['b' => ['c' => 'c1', 'd' => 'd1']], ['b' => ['c' => 'c2', 'd' => 'd2']], ['b' => ['c' => 'c1', 'd' => 'd1']], ['b' => ['c' => 'c2', 'd' => 'd2']]]]];
     $this->assertEquals($expected, $result->toArray());
     $this->assertSame($callCounts['id1'], 1);
     // Result for id1 is expected to be memoized after first call
     $this->assertSame($callCounts['id2'], 2);
 }
Ejemplo n.º 23
0
 /**
  * @it gets execution info in resolver
  */
 public function testGetsExecutionInfoInResolver()
 {
     $encounteredContext = null;
     $encounteredSchema = null;
     $encounteredRootValue = null;
     $PersonType2 = null;
     $NamedType2 = new InterfaceType(['name' => 'Named', 'fields' => ['name' => ['type' => Type::string()]], 'resolveType' => function ($obj, $context, ResolveInfo $info) use(&$encounteredContext, &$encounteredSchema, &$encounteredRootValue, &$PersonType2) {
         $encounteredContext = $context;
         $encounteredSchema = $info->schema;
         $encounteredRootValue = $info->rootValue;
         return $PersonType2;
     }]);
     $PersonType2 = new ObjectType(['name' => 'Person', 'interfaces' => [$NamedType2], 'fields' => ['name' => ['type' => Type::string()], 'friends' => ['type' => Type::listOf($NamedType2)]]]);
     $schema2 = new Schema(['query' => $PersonType2]);
     $john2 = new Person('John', [], [$this->liz]);
     $context = ['authToken' => '123abc'];
     $ast = Parser::parse('{ name, friends { name } }');
     $this->assertEquals(['data' => ['name' => 'John', 'friends' => [['name' => 'Liz']]]], GraphQL::execute($schema2, $ast, $john2, $context));
     $this->assertSame($context, $encounteredContext);
     $this->assertSame($schema2, $encounteredSchema);
     $this->assertSame($john2, $encounteredRootValue);
 }
Ejemplo n.º 24
0
    public function testExecutesArbitraryCode()
    {
        $deepData = null;
        $data = ['a' => function () {
            return 'Apple';
        }, 'b' => function () {
            return 'Banana';
        }, 'c' => function () {
            return 'Cookie';
        }, 'd' => function () {
            return 'Donut';
        }, 'e' => function () {
            return 'Egg';
        }, 'f' => 'Fish', 'pic' => function ($size = 50) {
            return 'Pic of size: ' . $size;
        }, 'promise' => function () use(&$data) {
            return $data;
        }, 'deep' => function () use(&$deepData) {
            return $deepData;
        }];
        $deepData = ['a' => function () {
            return 'Already Been Done';
        }, 'b' => function () {
            return 'Boring';
        }, 'c' => function () {
            return ['Contrived', null, 'Confusing'];
        }, 'deeper' => function () use($data) {
            return [$data, null, $data];
        }];
        $doc = '
      query Example($size: Int) {
        a,
        b,
        x: c
        ...c
        f
        ...on DataType {
          pic(size: $size)
          promise {
            a
          }
        }
        deep {
          a
          b
          c
          deeper {
            a
            b
          }
        }
      }

      fragment c on DataType {
        d
        e
      }
    ';
        $ast = Parser::parse($doc);
        $expected = ['data' => ['a' => 'Apple', 'b' => 'Banana', 'x' => 'Cookie', 'd' => 'Donut', 'e' => 'Egg', 'f' => 'Fish', 'pic' => 'Pic of size: 100', 'promise' => ['a' => 'Apple'], 'deep' => ['a' => 'Already Been Done', 'b' => 'Boring', 'c' => ['Contrived', null, 'Confusing'], 'deeper' => [['a' => 'Apple', 'b' => 'Banana'], null, ['a' => 'Apple', 'b' => 'Banana']]]]];
        $deepDataType = null;
        $dataType = new ObjectType(['name' => 'DataType', 'fields' => ['a' => ['type' => Type::string()], 'b' => ['type' => Type::string()], 'c' => ['type' => Type::string()], 'd' => ['type' => Type::string()], 'e' => ['type' => Type::string()], 'f' => ['type' => Type::string()], 'pic' => ['args' => ['size' => ['type' => Type::int()]], 'type' => Type::string(), 'resolve' => function ($obj, $args) {
            return $obj['pic']($args['size']);
        }], 'promise' => ['type' => function () use(&$dataType) {
            return $dataType;
        }], 'deep' => ['type' => function () use(&$deepDataType) {
            return $deepDataType;
        }]]]);
        $deepDataType = new ObjectType(['name' => 'DeepDataType', 'fields' => ['a' => ['type' => Type::string()], 'b' => ['type' => Type::string()], 'c' => ['type' => Type::listOf(Type::string())], 'deeper' => ['type' => Type::listOf($dataType)]]]);
        $schema = new Schema($dataType);
        $this->assertEquals($expected, Executor::execute($schema, $ast, $data, ['size' => 100], 'Example')->toArray());
    }
Ejemplo n.º 25
0
 private function schema()
 {
     $dataType = new ObjectType(['name' => 'DataType', 'fields' => ['list' => ['type' => Type::listOf(Type::int())], 'listOfNonNull' => ['type' => Type::listOf(Type::nonNull(Type::int()))], 'nonNullList' => ['type' => Type::nonNull(Type::listOf(Type::int()))], 'nonNullListOfNonNull' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(Type::int())))], 'listContainsNull' => ['type' => Type::listOf(Type::int())], 'listOfNonNullContainsNull' => ['type' => Type::listOf(Type::nonNull(Type::int()))], 'nonNullListContainsNull' => ['type' => Type::nonNull(Type::listOf(Type::int()))], 'nonNullListOfNonNullContainsNull' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(Type::int())))], 'listReturnsNull' => ['type' => Type::listOf(Type::int())], 'listOfNonNullReturnsNull' => ['type' => Type::listOf(Type::nonNull(Type::int()))], 'nonNullListReturnsNull' => ['type' => Type::nonNull(Type::listOf(Type::int()))], 'nonNullListOfNonNullReturnsNull' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(Type::int())))], 'nest' => ['type' => function () use(&$dataType) {
         return $dataType;
     }]]]);
     $schema = new Schema($dataType);
     return $schema;
 }
Ejemplo n.º 26
0
 /**
  * @it resolveType allows resolving with type name
  */
 public function testResolveTypeAllowsResolvingWithTypeName()
 {
     $PetType = new InterfaceType(['name' => 'Pet', 'resolveType' => function ($obj) {
         if ($obj instanceof Dog) {
             return 'Dog';
         }
         if ($obj instanceof Cat) {
             return 'Cat';
         }
         return null;
     }, 'fields' => ['name' => ['type' => Type::string()]]]);
     $DogType = new ObjectType(['name' => 'Dog', 'interfaces' => [$PetType], 'fields' => ['name' => ['type' => Type::string()], 'woofs' => ['type' => Type::boolean()]]]);
     $CatType = new ObjectType(['name' => 'Cat', 'interfaces' => [$PetType], 'fields' => ['name' => ['type' => Type::string()], 'meows' => ['type' => Type::boolean()]]]);
     $schema = new Schema(['query' => new ObjectType(['name' => 'Query', 'fields' => ['pets' => ['type' => Type::listOf($PetType), 'resolve' => function () {
         return [new Dog('Odie', true), new Cat('Garfield', false)];
     }]]]), 'types' => [$CatType, $DogType]]);
     $query = '{
       pets {
         name
         ... on Dog {
           woofs
         }
         ... on Cat {
           meows
         }
       }
     }';
     $result = GraphQL::execute($schema, $query);
     $this->assertEquals(['data' => ['pets' => [['name' => 'Odie', 'woofs' => true], ['name' => 'Garfield', 'meows' => false]]]], $result);
 }
Ejemplo n.º 27
0
 /**
  * Create ConnectionType.
  *
  * @param  string $name
  * @param  mixed $type
  * @param Closure $injectCursor
  * @return ObjectType
  */
 protected function connectionType($name, $type, Closure $injectCursor = null)
 {
     if (!$type instanceof ListOfType) {
         $type = Type::listOf($type);
     }
     return new ObjectType(['name' => ucfirst($name) . 'Connection', 'fields' => ['edges' => ['type' => $type, 'resolve' => function ($collection, array $args, ResolveInfo $info) use($injectCursor) {
         if ($injectCursor) {
             return $injectCursor($collection, $args, $info);
         }
         return $this->injectCursor($collection);
     }], 'pageInfo' => ['type' => Type::nonNull($this->pageInfoType()), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection, array $args, ResolveInfo $info) {
         return $collection;
     }]]]);
 }
Ejemplo n.º 28
0
 public function schema()
 {
     $TestInputObject = new InputObjectType(['name' => 'TestInputObject', 'fields' => ['a' => ['type' => Type::string()], 'b' => ['type' => Type::listOf(Type::string())], 'c' => ['type' => Type::nonNull(Type::string())]]]);
     $TestType = new ObjectType(['name' => 'TestType', 'fields' => ['fieldWithObjectInput' => ['type' => Type::string(), 'args' => ['input' => ['type' => $TestInputObject]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }], 'fieldWithNullableStringInput' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::string()]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }], 'fieldWithNonNullableStringInput' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::nonNull(Type::string())]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }], 'list' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::listOf(Type::string())]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }], 'nnList' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::nonNull(Type::listOf(Type::string()))]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }], 'listNN' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::listOf(Type::nonNull(Type::string()))]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }], 'nnListNN' => ['type' => Type::string(), 'args' => ['input' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(Type::string())))]], 'resolve' => function ($_, $args) {
         return json_encode($args['input']);
     }]]]);
     $schema = new Schema($TestType);
     return $schema;
 }
Ejemplo n.º 29
0
 public static function _field()
 {
     if (!isset(self::$map['__Field'])) {
         self::$map['__Field'] = new ObjectType(['name' => '__Field', 'description' => 'Object and Interface types are described by a list of Fields, each of ' . 'which has a name, potentially a list of arguments, and a return type.', 'fields' => function () {
             return ['name' => ['type' => Type::nonNull(Type::string())], 'description' => ['type' => Type::string()], 'args' => ['type' => Type::nonNull(Type::listOf(Type::nonNull(self::_inputValue()))), 'resolve' => function (FieldDefinition $field) {
                 return empty($field->args) ? [] : $field->args;
             }], 'type' => ['type' => Type::nonNull(self::_type()), 'resolve' => function ($field) {
                 return $field->getType();
             }], 'isDeprecated' => ['type' => Type::nonNull(Type::boolean()), 'resolve' => function (FieldDefinition $field) {
                 return !!$field->deprecationReason;
             }], 'deprecationReason' => ['type' => Type::string()]];
         }]);
     }
     return self::$map['__Field'];
 }
Ejemplo n.º 30
0
 /**
  * Create valid GraphQL input field using field key and definition array.
  *
  * @param string $fieldKey
  * @param array  $fieldValue
  *
  * @return array
  */
 protected function buildInputField($fieldKey, $fieldValue)
 {
     if (!isset($this->inputAlambicTypes[$fieldValue['type']]) && isset($this->alambicTypeDefs[$fieldValue['type']])) {
         $this->loadInputAlambicType($fieldValue['type'], $this->alambicTypeDefs[$fieldValue['type']]);
     }
     $baseTypeResult = $this->inputAlambicTypes[$fieldValue['type']];
     if (isset($fieldValue['multivalued']) && $fieldValue['multivalued']) {
         $baseTypeResult = Type::listOf($baseTypeResult);
     }
     if (isset($fieldValue['required']) && $fieldValue['required']) {
         $baseTypeResult = Type::nonNull($baseTypeResult);
     }
     $fieldResult = ['type' => $baseTypeResult];
     if (!empty($fieldValue['description'])) {
         $fieldResult['description'] = $fieldValue['description'];
     }
     if (!empty($fieldValue['defaultValue'])) {
         $fieldResult['defaultValue'] = $fieldValue['defaultValue'];
     }
     return $fieldResult;
 }