Skip to content

Commit

Permalink
Merge branch 'master' into fix-type-registry-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Nov 30, 2023
2 parents fbc429d + 687f3f2 commit c77810b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"nyholm/psr7": "^1.5",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "1.10.41",
"phpstan/phpstan": "1.10.45",
"phpstan/phpstan-phpunit": "1.3.15",
"phpstan/phpstan-strict-rules": "1.5.2",
"phpunit/phpunit": "^9.5 || ^10",
Expand All @@ -32,7 +32,7 @@
"react/promise": "^2.9",
"rector/rector": "^0.18",
"symfony/polyfill-php81": "^1.23",
"symfony/var-exporter": "^5 || ^6",
"symfony/var-exporter": "^5 || ^6 || ^7",
"thecodingmachine/safe": "^1.3 || ^2"
},
"suggest": {
Expand Down
1 change: 1 addition & 0 deletions docs/complementary-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [GraphQL Batch Processor](https://github.com/vasily-kartashov/graphql-batch-processing) – Provides a builder interface for defining collection, querying, filtering, and post-processing logic of batched data fetches
- [GraphQL Utils](https://github.com/simPod/GraphQL-Utils) – Objective schema definition builders (no need for arrays anymore)
- [Relay Library](https://github.com/ivome/graphql-relay-php) – Helps construct Relay related schema definitions
- [Resonance/GraphQL](https://resonance.distantmagic.com/docs/features/graphql/) – Integrates with Swoole for parallelism. Define your schema code-first with annotations.
- [GraphQL PHP Validation Toolkit](https://github.com/shmax/graphql-php-validation-toolkit) - Small library for validation of user input

* [MLL Scalars](https://github.com/mll-lab/graphql-php-scalars) - Collection of custom scalar types
Expand Down
3 changes: 3 additions & 0 deletions docs/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ Where **$promiseAdapter** is an instance of:
- For [AMPHP](https://github.com/amphp/amp): <br>
`GraphQL\Executor\Promise\Adapter\AmpPromiseAdapter`

- For [Swoole](https://swoole.com/) or [OpenSwoole](https://openswoole.com/): <br>
You can use an external library: [Resonance](https://resonance.distantmagic.com/docs/features/graphql/standalone-promise-adapter.html)

- Other platforms: write your own class implementing interface: <br>
[`GraphQL\Executor\Promise\PromiseAdapter`](class-reference.md#graphqlexecutorpromisepromiseadapter).

Expand Down
20 changes: 6 additions & 14 deletions src/Language/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ public function printAST(Node $node): string
}

/** @throws \JsonException */
protected function p(?Node $node, bool $isDescription = false): string
protected function p(?Node $node): string
{
if ($node === null) {
return '';
}

switch (true) {
case $node instanceof ArgumentNode:
case $node instanceof ObjectFieldNode:
return $this->p($node->name) . ': ' . $this->p($node->value);

case $node instanceof BooleanValueNode:
Expand Down Expand Up @@ -166,6 +167,9 @@ protected function p(?Node $node, bool $isDescription = false): string
);

case $node instanceof EnumValueNode:
case $node instanceof FloatValueNode:
case $node instanceof IntValueNode:
case $node instanceof NameNode:
return $node->value;

case $node instanceof FieldDefinitionNode:
Expand Down Expand Up @@ -219,9 +223,6 @@ protected function p(?Node $node, bool $isDescription = false): string
' '
);

case $node instanceof FloatValueNode:
return $node->value;

case $node instanceof FragmentDefinitionNode:
// Note: fragment variable definitions are experimental and may be changed or removed in the future.
return 'fragment ' . $this->p($node->name)
Expand Down Expand Up @@ -310,18 +311,12 @@ protected function p(?Node $node, bool $isDescription = false): string
' '
);

case $node instanceof IntValueNode:
return $node->value;

case $node instanceof ListTypeNode:
return '[' . $this->p($node->type) . ']';

case $node instanceof ListValueNode:
return '[' . $this->printList($node->values, ', ') . ']';

case $node instanceof NameNode:
return $node->value;

case $node instanceof NamedTypeNode:
return $this->p($node->name);

Expand All @@ -331,9 +326,6 @@ protected function p(?Node $node, bool $isDescription = false): string
case $node instanceof NullValueNode:
return 'null';

case $node instanceof ObjectFieldNode:
return $this->p($node->name) . ': ' . $this->p($node->value);

case $node instanceof ObjectTypeDefinitionNode:
return $this->addDescription($node->description, $this->join(
[
Expand Down Expand Up @@ -511,7 +503,7 @@ protected function printListBlock(NodeList $list): string
/** @throws \JsonException */
protected function addDescription(?StringValueNode $description, string $body): string
{
return $this->join([$this->p($description, true), $body], "\n");
return $this->join([$this->p($description), $body], "\n");
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/Type/EnumTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ public function setUp(): void
}

if ($args['provideTwo'] ?? false) {
return ['two', 'TWO'];
return [
'two',
'TWO',
];
}

return $args['fromEnum'];
Expand Down

0 comments on commit c77810b

Please sign in to comment.