Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaPrinter: Directives support 🤩 #996

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
INPUT_OBJECT support.
LastDragon-ru committed Nov 20, 2021
commit 7d5eafd36016d32c17a2272a2e8845dfbb4d35d1
3 changes: 2 additions & 1 deletion src/Utils/SchemaPrinter.php
Original file line number Diff line number Diff line change
@@ -503,6 +503,7 @@ static function ($f, $i) use ($options): string {

return static::printDescription($options, $type) .
sprintf('input %s', $type->name) .
static::printTypeDirectives($type, $options) .
static::printBlock($fields);
}

@@ -517,7 +518,7 @@ protected static function printBlock(array $items): string
}

/**
* @param Type|EnumValueDefinition|EnumType|InterfaceType|FieldDefinition|UnionType $type
* @param Type|EnumValueDefinition|EnumType|InterfaceType|FieldDefinition|UnionType|InputObjectType $type
* @param array<string, bool> $options
* @phpstan-param Options $options
*/
17 changes: 17 additions & 0 deletions tests/Utils/SchemaPrinterTest.php
Original file line number Diff line number Diff line change
@@ -1339,6 +1339,14 @@ interface InterfaceB implements InterfaceA @test(value: "{$text}") {
union UnionA @test = TypeA | TypeB

union UnionB @test(value: "{$text}") = TypeA | TypeB

input InputA @test {
a: Int
}

input InputB @test(value: "{$text}") {
a: ID
}
GRAPHQL;
$expected = /** @lang GraphQL */ <<<'GRAPHQL'
directive @test(value: String) on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
@@ -1367,6 +1375,15 @@ enum EnumB
a
}

input InputA @test {
a: Int
}

input InputB
@test(value: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") {
a: ID
}

interface InterfaceA @test {
a: Int @test @deprecated