Skip to content

Commit

Permalink
feat(graphql/SchemaPrinter)!: Removed support of directive in descrip…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
LastDragon-ru committed Oct 29, 2022
1 parent d2668a9 commit 86d3547
Show file tree
Hide file tree
Showing 20 changed files with 17 additions and 663 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,6 @@ protected function description(): ?Description {
$description = $definition->description;
}

// Directives
if ($this->getSettings()->isPrintDirectivesInDescription()) {
$directives = (string) $this->addUsed($this->directives(0, mb_strlen($this->indent())));

if ($directives) {
$eol = $description ? $this->eol() : '';
$directives = <<<DIRECTIVES
```graphql
{$directives}
```
DIRECTIVES;
$description = "{$description}{$eol}{$eol}{$directives}";
}
}

// Return
return new Description(
$this->getSettings(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use Closure;
use GraphQL\Language\Parser;
use GraphQL\Type\Definition\Directive;
use GraphQL\Type\Definition\EnumType;
use GraphQL\Type\Definition\EnumValueDefinition;
use LastDragon_ru\LaraASP\GraphQL\SchemaPrinter\Contracts\Settings;
use LastDragon_ru\LaraASP\GraphQL\SchemaPrinter\Misc\DirectiveResolver;
use LastDragon_ru\LaraASP\GraphQL\SchemaPrinter\Misc\PrinterSettings;
Expand Down Expand Up @@ -58,7 +56,7 @@ public function dataProviderToString(): array {
->setNormalizeEnums(false);

return [
'enum' => [
'enum' => [
<<<'STRING'
enum Test {
C
Expand All @@ -74,7 +72,7 @@ enum Test {
'values' => ['C', 'B', 'A'],
]),
],
'indent' => [
'indent' => [
<<<'STRING'
enum Test {
C
Expand All @@ -90,7 +88,7 @@ enum Test {
'values' => ['C', 'B', 'A'],
]),
],
'normalized' => [
'normalized' => [
<<<'STRING'
enum Test {
A
Expand All @@ -106,59 +104,6 @@ enum Test {
'values' => ['C', 'B', 'A'],
]),
],
'directives and description' => [
<<<'STRING'
enum Test {
C
"""
Description
```graphql
@b
@a
```
"""
B
@b
@a
"""
```graphql
@deprecated
```
"""
A
@deprecated
}
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
static function (): EnumType {
$enum = new EnumType([
'name' => 'Test',
'values' => ['C', 'B', 'A'],
]);

$a = $enum->getValue('A');

if ($a instanceof EnumValueDefinition) {
$a->deprecationReason = Directive::DEFAULT_DEPRECATION_REASON;
}

$b = $enum->getValue('B');

if ($b instanceof EnumValueDefinition) {
$b->astNode = Parser::enumValueDefinition('A @b @a');
$b->description = 'Description';
}

return $enum;
},
],
];
}
// </editor-fold>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function dataProviderToString(): array {
$settings = new TestSettings();

return [
'value' => [
'value' => [
<<<'STRING'
A
STRING,
Expand All @@ -59,7 +59,7 @@ public function dataProviderToString(): array {
'value' => 'A',
]),
],
'indent' => [
'indent' => [
<<<'STRING'
A
STRING,
Expand All @@ -71,30 +71,6 @@ public function dataProviderToString(): array {
'value' => 'A',
]),
],
'description and directives' => [
<<<'STRING'
"""
Description
```graphql
@a
```
"""
A
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
new EnumValueDefinition([
'name' => 'A',
'value' => 'A',
'astNode' => Parser::enumValueDefinition('A @a'),
'description' => 'Description',
]),
],
];
}
// </editor-fold>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,11 @@ public function dataProviderToString(): array {
<<<'STRING'
"""
Description
```graphql
@a
```
"""
test: Test!
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ public function dataProviderToString(): array {
<<<'STRING'
"""
Description
```graphql
@a
```
"""
input Test
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,11 @@ public function dataProviderToString(): array {
<<<'STRING'
"""
Description
```graphql
@a
```
"""
test: Test!
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,11 @@ public function dataProviderToString(): array {
<<<'STRING'
"""
Description
```graphql
@a
```
"""
interface Test
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,11 @@ public function dataProviderToString(): array {
<<<'STRING'
"""
Description
```graphql
@a
```
"""
type Test
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function dataProviderToString(): array {
->setPrintDirectives(false);

return [
'scalar' => [
'scalar' => [
<<<'STRING'
scalar Test
STRING,
Expand All @@ -61,58 +61,7 @@ public function dataProviderToString(): array {
'name' => 'Test',
]),
],
'with description and directives' => [
<<<'STRING'
"""
Description
```graphql
@a
```
"""
scalar Test
@a
STRING,
$settings
->setPrintDirectivesInDescription(true)
->setPrintDirectives(true),
0,
0,
new CustomScalarType([
'name' => 'Test',
'description' => 'Description',
'astNode' => Parser::scalarTypeDefinition(
<<<'STRING'
scalar Test @a
STRING,
),
]),
],
'with directives in description' => [
<<<'STRING'
"""
Description
```graphql
@a
```
"""
scalar Test
STRING,
$settings->setPrintDirectivesInDescription(true),
0,
0,
new CustomScalarType([
'name' => 'Test',
'description' => 'Description',
'astNode' => Parser::scalarTypeDefinition(
<<<'STRING'
scalar Test @a
STRING,
),
]),
],
'indent' => [
'indent' => [
<<<'STRING'
"""
Description
Expand All @@ -136,7 +85,7 @@ public function dataProviderToString(): array {
),
]),
],
'indent + no description' => [
'indent + no description' => [
<<<'STRING'
scalar Test
@a(
Expand Down
Loading

0 comments on commit 86d3547

Please sign in to comment.