@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' . |
34 | 34 | 'exposes all available types and directives on the server, as well as ' . |
35 | 35 | 'the entry points for query, mutation, and subscription operations.', |
36 | - 'fields' => function () { |
|
36 | + 'fields' => function() { |
|
37 | 37 | return [ |
38 | 38 | 'types' => [ |
39 | 39 | 'description' => 'A list of all types supported by this server.', |
40 | 40 | 'type' => GraphQLNonNull(GraphQLList(GraphQLNonNull(__Type()))), |
41 | - 'resolve' => function (SchemaInterface $schema): array { |
|
41 | + 'resolve' => function(SchemaInterface $schema): array { |
|
42 | 42 | return array_values($schema->getTypeMap()); |
43 | 43 | }, |
44 | 44 | ], |
45 | 45 | 'queryType' => [ |
46 | 46 | 'description' => 'The type that query operations will be rooted at.', |
47 | 47 | 'type' => GraphQLNonNull(__Type()), |
48 | - 'resolve' => function (SchemaInterface $schema): ObjectType { |
|
48 | + 'resolve' => function(SchemaInterface $schema): ObjectType { |
|
49 | 49 | return $schema->getQuery(); |
50 | 50 | }, |
51 | 51 | ], |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'If this server supports mutation, the type that ' . |
55 | 55 | 'mutation operations will be rooted at.', |
56 | 56 | 'type' => __Type(), |
57 | - 'resolve' => function (SchemaInterface $schema): ObjectType { |
|
57 | + 'resolve' => function(SchemaInterface $schema): ObjectType { |
|
58 | 58 | return $schema->getMutation(); |
59 | 59 | }, |
60 | 60 | ], |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | 'If this server support subscription, the type that ' . |
64 | 64 | 'subscription operations will be rooted at.', |
65 | 65 | 'type' => __Type(), |
66 | - 'resolve' => function (SchemaInterface $schema): ObjectType { |
|
66 | + 'resolve' => function(SchemaInterface $schema): ObjectType { |
|
67 | 67 | return $schema->getSubscription(); |
68 | 68 | }, |
69 | 69 | ], |
70 | 70 | 'directives' => [ |
71 | 71 | 'description' => 'A list of all directives supported by this server.', |
72 | 72 | 'type' => GraphQLNonNull(GraphQLList(GraphQLNonNull(__Directive()))), |
73 | - 'resolve' => function (SchemaInterface $schema): array { |
|
73 | + 'resolve' => function(SchemaInterface $schema): array { |
|
74 | 74 | return $schema->getDirectives(); |
75 | 75 | }, |
76 | 76 | ], |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | 'execution behavior in ways field arguments will not suffice, such as ' . |
101 | 101 | 'conditionally including or skipping a field. Directives provide this by ' . |
102 | 102 | 'describing additional information to the executor.', |
103 | - 'fields' => function () { |
|
103 | + 'fields' => function() { |
|
104 | 104 | return [ |
105 | 105 | 'name' => ['type' => GraphQLNonNull(GraphQLString())], |
106 | 106 | 'description' => ['type' => GraphQLString()], |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ], |
110 | 110 | 'args' => [ |
111 | 111 | 'type' => GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue()))), |
112 | - 'resolve' => function (DirectiveInterface $directive): array { |
|
112 | + 'resolve' => function(DirectiveInterface $directive): array { |
|
113 | 113 | return $directive->getArgs() ?: []; |
114 | 114 | }, |
115 | 115 | ], |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | 'Object and Interface types provide the fields they describe. Abstract ' . |
218 | 218 | 'types, Union and Interface, provide the Object types possible ' . |
219 | 219 | 'at runtime. List and NonNull types compose other types.', |
220 | - 'fields' => function () { |
|
220 | + 'fields' => function() { |
|
221 | 221 | return [ |
222 | 222 | 'kind' => [ |
223 | 223 | 'type' => GraphQLNonNull(__TypeKind()), |
224 | - 'resolve' => function (TypeInterface $type) { |
|
224 | + 'resolve' => function(TypeInterface $type) { |
|
225 | 225 | if ($type instanceof ScalarType) { |
226 | 226 | return TypeKindEnum::SCALAR; |
227 | 227 | } |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | 'args' => [ |
258 | 258 | 'includeDeprecated' => ['type' => GraphQLBoolean(), 'defaultValue' => false], |
259 | 259 | ], |
260 | - 'resolve' => function (TypeInterface $type, array $args): ?array { |
|
260 | + 'resolve' => function(TypeInterface $type, array $args): ?array { |
|
261 | 261 | list ($includeDeprecated) = $args; |
262 | 262 | |
263 | 263 | if ($type instanceof ObjectType || $type instanceof InterfaceType) { |
264 | 264 | $fields = array_values($type->getFields()); |
265 | 265 | |
266 | 266 | if (!$includeDeprecated) { |
267 | - $fields = array_filter($fields, function (Field $field) { |
|
267 | + $fields = array_filter($fields, function(Field $field) { |
|
268 | 268 | return !$field->isDeprecated(); |
269 | 269 | }); |
270 | 270 | } |
@@ -277,13 +277,13 @@ discard block |
||
277 | 277 | ], |
278 | 278 | 'interfaces' => [ |
279 | 279 | 'type' => GraphQLList(GraphQLNonNull(__Type())), |
280 | - 'resolve' => function (TypeInterface $type): ?array { |
|
280 | + 'resolve' => function(TypeInterface $type): ?array { |
|
281 | 281 | return $type instanceof ObjectType ? $type->getInterfaces() : null; |
282 | 282 | }, |
283 | 283 | ], |
284 | 284 | 'possibleTypes' => [ |
285 | 285 | 'type' => GraphQLList(GraphQLNonNull(__Type())), |
286 | - 'resolve' => function (TypeInterface $type, $args, $context, $info): ?array { |
|
286 | + 'resolve' => function(TypeInterface $type, $args, $context, $info): ?array { |
|
287 | 287 | /** @var SchemaInterface $schema */ |
288 | 288 | list ($schema) = $info; |
289 | 289 | return $type instanceof AbstractType ? $schema->getPossibleTypes($type) : null; |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | 'args' => [ |
295 | 295 | 'includeDeprecated' => ['type' => GraphQLBoolean(), 'defaultValue' => false], |
296 | 296 | ], |
297 | - 'resolve' => function (TypeInterface $type, array $args): ?array { |
|
297 | + 'resolve' => function(TypeInterface $type, array $args): ?array { |
|
298 | 298 | list ($includeDeprecated) = $args; |
299 | 299 | |
300 | 300 | if ($type instanceof EnumType) { |
301 | 301 | $values = array_values($type->getValues()); |
302 | 302 | |
303 | 303 | if (!$includeDeprecated) { |
304 | - $values = array_filter($values, function (Field $field) { |
|
304 | + $values = array_filter($values, function(Field $field) { |
|
305 | 305 | return !$field->isDeprecated(); |
306 | 306 | }); |
307 | 307 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | ], |
315 | 315 | 'inputFields' => [ |
316 | 316 | 'type' => GraphQLList(GraphQLNonNull(__InputValue())), |
317 | - 'resolve' => function (TypeInterface $type): ?array { |
|
317 | + 'resolve' => function(TypeInterface $type): ?array { |
|
318 | 318 | return $type instanceof InputObjectType ? $type->getFields() : null; |
319 | 319 | }, |
320 | 320 | ], |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | 'description' => |
342 | 342 | 'Object and Interface types are described by a list of Fields, each of ' . |
343 | 343 | 'which has a name, potentially a list of arguments, and a return type.', |
344 | - 'fields' => function () { |
|
344 | + 'fields' => function() { |
|
345 | 345 | return [ |
346 | 346 | 'name' => ['type' => GraphQLNonNull(GraphQLString())], |
347 | 347 | 'description' => ['type' => GraphQLString()], |
348 | 348 | 'args' => [ |
349 | 349 | 'type' => GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue()))), |
350 | - 'resolve' => function (DirectiveInterface $directive): array { |
|
350 | + 'resolve' => function(DirectiveInterface $directive): array { |
|
351 | 351 | return $directive->getArgs() ?: []; |
352 | 352 | }, |
353 | 353 | ], |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | 'Arguments provided to Fields or Directives and the input fields of an ' . |
378 | 378 | 'InputObject are represented as Input Values which describe their type ' . |
379 | 379 | 'and optionally a default value.', |
380 | - 'fields' => function () { |
|
380 | + 'fields' => function() { |
|
381 | 381 | return [ |
382 | 382 | 'name' => ['type' => GraphQLNonNull(GraphQLString())], |
383 | 383 | 'description' => ['type' => GraphQLString()], |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | 'description' => |
388 | 388 | 'A GraphQL-formatted string representing the default value for this ' . |
389 | 389 | 'input value.', |
390 | - 'resolve' => function ($inputValue) { |
|
390 | + 'resolve' => function($inputValue) { |
|
391 | 391 | // TODO: Implement this when we have support for printing AST. |
392 | 392 | return null; |
393 | 393 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | 'One possible value for a given Enum. Enum values are unique values, not ' . |
416 | 416 | 'a placeholder for a string or numeric value. However an Enum value is ' . |
417 | 417 | 'returned in a JSON response as a string.', |
418 | - 'fields' => function () { |
|
418 | + 'fields' => function() { |
|
419 | 419 | return [ |
420 | 420 | 'name' => ['type' => GraphQLNonNull(GraphQLString())], |
421 | 421 | 'description' => ['type' => GraphQLString()], |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | 'name' => '__schema', |
481 | 481 | 'type' => GraphQLNonNull(__Schema()), |
482 | 482 | 'description' => 'Access the current type schema of this server.', |
483 | - 'resolve' => function ($source, $args, $context, $info): SchemaInterface { |
|
483 | + 'resolve' => function($source, $args, $context, $info): SchemaInterface { |
|
484 | 484 | list ($schema) = $info; |
485 | 485 | return $schema; |
486 | 486 | } |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'args' => [ |
501 | 501 | 'name' => ['type' => GraphQLNonNull(GraphQLString())], |
502 | 502 | ], |
503 | - 'resolve' => function ($source, $args, $context, $info): TypeInterface { |
|
503 | + 'resolve' => function($source, $args, $context, $info): TypeInterface { |
|
504 | 504 | /** @var SchemaInterface $schema */ |
505 | 505 | list ($name) = $args; |
506 | 506 | list ($schema) = $info; |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | 'name' => '__typename', |
520 | 520 | 'type' => GraphQLNonNull(GraphQLString()), |
521 | 521 | 'description' => 'The name of the current Object type at runtime.', |
522 | - 'resolve' => function ($source, $args, $context, $info): string { |
|
522 | + 'resolve' => function($source, $args, $context, $info): string { |
|
523 | 523 | /** @var TypeInterface $parentType */ |
524 | 524 | list ($parentType) = $info; |
525 | 525 | return $parentType->getName(); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | { |
553 | 553 | return arraySome( |
554 | 554 | introspectionTypes(), |
555 | - function (TypeInterface $introspectionType) use ($type) { |
|
555 | + function(TypeInterface $introspectionType) use ($type) { |
|
556 | 556 | return $type->getName() === $introspectionType->getName(); |
557 | 557 | } |
558 | 558 | ); |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | */ |
232 | 232 | protected function registerParser() |
233 | 233 | { |
234 | - $this->shared(NodeBuilderInterface::class, function () { |
|
234 | + $this->shared(NodeBuilderInterface::class, function() { |
|
235 | 235 | return new NodeBuilder(self::getNodeBuilders()); |
236 | 236 | }); |
237 | 237 | |
238 | 238 | $this->shared(ParserInterface::class, Parser::class) |
239 | 239 | ->withArgument(NodeBuilderInterface::class); |
240 | 240 | |
241 | - $this->bind(LexerInterface::class, function () { |
|
241 | + $this->bind(LexerInterface::class, function() { |
|
242 | 242 | return new Lexer(self::getSourceReaders()); |
243 | 243 | }); |
244 | 244 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | { |
256 | 256 | $this->shared(DefinitionBuilderInterface::class, DefinitionBuilder::class) |
257 | 257 | ->withArguments([ |
258 | - function (NamedTypeNode $node) { |
|
258 | + function(NamedTypeNode $node) { |
|
259 | 259 | throw new \Exception(sprintf('Type "%s" not found in document.', $node->getNameValue())); |
260 | 260 | }, |
261 | 261 | CacheInterface::class, |
@@ -284,18 +284,18 @@ discard block |
||
284 | 284 | return (bool)$value; |
285 | 285 | } |
286 | 286 | |
287 | - $this->shared('GraphQLBoolean', function () { |
|
287 | + $this->shared('GraphQLBoolean', function() { |
|
288 | 288 | return GraphQLScalarType([ |
289 | 289 | 'name' => TypeNameEnum::BOOLEAN, |
290 | 290 | 'description' => 'The `Boolean` scalar type represents `true` or `false`.', |
291 | - 'serialize' => function ($value) { |
|
291 | + 'serialize' => function($value) { |
|
292 | 292 | return coerceBoolean($value); |
293 | 293 | }, |
294 | - 'parseValue' => function ($value) { |
|
294 | + 'parseValue' => function($value) { |
|
295 | 295 | return coerceBoolean($value); |
296 | 296 | }, |
297 | 297 | |
298 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
298 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
299 | 299 | /** @var BooleanValueNode $astNode */ |
300 | 300 | return $astNode->getKind() === NodeKindEnum::BOOLEAN ? $astNode->getValue() : null; |
301 | 301 | }, |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | throw new \TypeError(sprintf('Float cannot represent non numeric value: %s', $value)); |
321 | 321 | } |
322 | 322 | |
323 | - $this->shared('GraphQLFloat', function () { |
|
323 | + $this->shared('GraphQLFloat', function() { |
|
324 | 324 | return GraphQLScalarType([ |
325 | 325 | 'name' => TypeNameEnum::FLOAT, |
326 | 326 | 'description' => |
327 | 327 | 'The `Float` scalar type represents signed double-precision fractional ' . |
328 | 328 | 'values as specified by ' . |
329 | 329 | '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).', |
330 | - 'serialize' => function ($value) { |
|
330 | + 'serialize' => function($value) { |
|
331 | 331 | return coerceFloat($value); |
332 | 332 | }, |
333 | - 'parseValue' => function ($value) { |
|
333 | + 'parseValue' => function($value) { |
|
334 | 334 | return coerceFloat($value); |
335 | 335 | }, |
336 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
336 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
337 | 337 | /** @var FloatValueNode $astNode */ |
338 | 338 | return in_array($astNode->getKind(), [NodeKindEnum::FLOAT, NodeKindEnum::INT], true) |
339 | 339 | ? $astNode->getValue() |
@@ -371,19 +371,19 @@ discard block |
||
371 | 371 | return $intValue; |
372 | 372 | } |
373 | 373 | |
374 | - $this->shared('GraphQLInt', function () { |
|
374 | + $this->shared('GraphQLInt', function() { |
|
375 | 375 | return GraphQLScalarType([ |
376 | 376 | 'name' => TypeNameEnum::INT, |
377 | 377 | 'description' => |
378 | 378 | 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
379 | 379 | 'values. Int can represent values between -(2^31) and 2^31 - 1.', |
380 | - 'serialize' => function ($value) { |
|
380 | + 'serialize' => function($value) { |
|
381 | 381 | return coerceInt($value); |
382 | 382 | }, |
383 | - 'parseValue' => function ($value) { |
|
383 | + 'parseValue' => function($value) { |
|
384 | 384 | return coerceInt($value); |
385 | 385 | }, |
386 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
386 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
387 | 387 | /** @var IntValueNode $astNode */ |
388 | 388 | return $astNode->getKind() === NodeKindEnum::INT ? $astNode->getValue() : null; |
389 | 389 | }, |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | return (string)$value; |
417 | 417 | } |
418 | 418 | |
419 | - $this->shared('GraphQLID', function () { |
|
419 | + $this->shared('GraphQLID', function() { |
|
420 | 420 | return GraphQLScalarType([ |
421 | 421 | 'name' => TypeNameEnum::ID, |
422 | 422 | 'description' => |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | 'response as a String; however, it is not intended to be human-readable. ' . |
426 | 426 | 'When expected as an input type, any string (such as `"4"`) or integer ' . |
427 | 427 | '(such as `4`) input value will be accepted as an ID.', |
428 | - 'serialize' => function ($value) { |
|
428 | + 'serialize' => function($value) { |
|
429 | 429 | return coerceString($value); |
430 | 430 | }, |
431 | - 'parseValue' => function ($value) { |
|
431 | + 'parseValue' => function($value) { |
|
432 | 432 | return coerceString($value); |
433 | 433 | }, |
434 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
434 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
435 | 435 | /** @var StringValueNode $astNode */ |
436 | 436 | return in_array($astNode->getKind(), [NodeKindEnum::STRING, NodeKindEnum::INT], true) |
437 | 437 | ? $astNode->getValue() |
@@ -440,20 +440,20 @@ discard block |
||
440 | 440 | ]); |
441 | 441 | }); |
442 | 442 | |
443 | - $this->shared('GraphQLString', function () { |
|
443 | + $this->shared('GraphQLString', function() { |
|
444 | 444 | return GraphQLScalarType([ |
445 | 445 | 'name' => TypeNameEnum::STRING, |
446 | 446 | 'description' => |
447 | 447 | 'The `String` scalar type represents textual data, represented as UTF-8 ' . |
448 | 448 | 'character sequences. The String type is most often used by GraphQL to ' . |
449 | 449 | 'represent free-form human-readable text.', |
450 | - 'serialize' => function ($value) { |
|
450 | + 'serialize' => function($value) { |
|
451 | 451 | return coerceString($value); |
452 | 452 | }, |
453 | - 'parseValue' => function ($value) { |
|
453 | + 'parseValue' => function($value) { |
|
454 | 454 | return coerceString($value); |
455 | 455 | }, |
456 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
456 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
457 | 457 | /** @var StringValueNode $astNode */ |
458 | 458 | return $astNode->getKind() === NodeKindEnum::STRING ? $astNode->getValue() : null; |
459 | 459 | }, |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | protected function registerDirectives() |
468 | 468 | { |
469 | - $this->shared('GraphQLIncludeDirective', function () { |
|
469 | + $this->shared('GraphQLIncludeDirective', function() { |
|
470 | 470 | return GraphQLDirective([ |
471 | 471 | 'name' => 'include', |
472 | 472 | 'description' => |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | ]); |
487 | 487 | }); |
488 | 488 | |
489 | - $this->shared('GraphQLSkipDirective', function () { |
|
489 | + $this->shared('GraphQLSkipDirective', function() { |
|
490 | 490 | return GraphQLDirective([ |
491 | 491 | 'name' => 'skip', |
492 | 492 | 'description' => |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | ]); |
507 | 507 | }); |
508 | 508 | |
509 | - $this->shared('GraphQLDeprecatedDirective', function () { |
|
509 | + $this->shared('GraphQLDeprecatedDirective', function() { |
|
510 | 510 | return GraphQLDirective([ |
511 | 511 | 'name' => 'deprecated', |
512 | 512 | 'description' => 'Marks an element of a GraphQL schema as no longer supported.', |