create() public static method

public static create ( )
Esempio n. 1
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;
 }