From c1c203344ada09ca8c4cf0135db15ccd54a36d3d Mon Sep 17 00:00:00 2001 From: Katy Ereira Date: Tue, 11 Aug 2020 12:06:53 +0100 Subject: [PATCH] fix: deprecated fields (#11) * Add breaking test * Fix issue. --- src/Utils/FederatedSchemaPrinter.php | 1 + test/StarWarsSchema.php | 4 ++++ test/__snapshots__/SchemaTest__testSchemaSdl__1.php | 1 + test/__snapshots__/SchemaTest__testServiceSdl__1.yml | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Utils/FederatedSchemaPrinter.php b/src/Utils/FederatedSchemaPrinter.php index 21052ee..8253d2c 100644 --- a/src/Utils/FederatedSchemaPrinter.php +++ b/src/Utils/FederatedSchemaPrinter.php @@ -16,6 +16,7 @@ use GraphQL\Type\Definition\UnionType; use GraphQL\Type\Introspection; use GraphQL\Type\Schema; +use GraphQL\Utils\AST; use GraphQL\Utils\Utils; use Apollo\Federation\Types\EntityObjectType; diff --git a/test/StarWarsSchema.php b/test/StarWarsSchema.php index bc58874..6b10add 100644 --- a/test/StarWarsSchema.php +++ b/test/StarWarsSchema.php @@ -91,6 +91,10 @@ public static function getEpisodesSchema(): FederatedSchema 'resolve' => function () { return StarWarsData::getEpisodes(); } + ], + 'deprecatedEpisodes' => [ + 'type' => Type::nonNull(Type::listOf(Type::nonNull($episodeType))), + 'deprecationReason' => 'Because you should use the other one.' ] ] ]); diff --git a/test/__snapshots__/SchemaTest__testSchemaSdl__1.php b/test/__snapshots__/SchemaTest__testSchemaSdl__1.php index d73c00f..3fe54d4 100644 --- a/test/__snapshots__/SchemaTest__testSchemaSdl__1.php +++ b/test/__snapshots__/SchemaTest__testSchemaSdl__1.php @@ -28,6 +28,7 @@ type Query { episodes: [Episode!]! + deprecatedEpisodes: [Episode!]! @deprecated(reason: "Because you should use the other one.") _service: _Service! _entities(representations: [_Any!]!): [_Entity] } diff --git a/test/__snapshots__/SchemaTest__testServiceSdl__1.yml b/test/__snapshots__/SchemaTest__testServiceSdl__1.yml index d1a45fc..50afd0f 100644 --- a/test/__snapshots__/SchemaTest__testServiceSdl__1.yml +++ b/test/__snapshots__/SchemaTest__testServiceSdl__1.yml @@ -1,3 +1,3 @@ data: _service: - sdl: "\"\"\"A character in the Star Wars Trilogy\"\"\"\nextend type Character @key(fields: \"id\") {\n id: Int! @external\n name: String! @external\n locations: [Location]! @requires(fields: \"name\")\n}\n\n\"\"\"A film in the Star Wars Trilogy\"\"\"\ntype Episode @key(fields: \"id\") {\n id: Int! \n title: String! \n characters: [Character!]! @provides(fields: \"name\")\n}\n\n\"\"\"A location in the Star Wars Trilogy\"\"\"\nextend type Location @key(fields: \"id\") {\n id: Int! @external\n name: String! @external\n}\n\nextend type Query {\n episodes: [Episode!]! \n}\n" + sdl: "\"\"\"A character in the Star Wars Trilogy\"\"\"\nextend type Character @key(fields: \"id\") {\n id: Int! @external\n name: String! @external\n locations: [Location]! @requires(fields: \"name\")\n}\n\n\"\"\"A film in the Star Wars Trilogy\"\"\"\ntype Episode @key(fields: \"id\") {\n id: Int! \n title: String! \n characters: [Character!]! @provides(fields: \"name\")\n}\n\n\"\"\"A location in the Star Wars Trilogy\"\"\"\nextend type Location @key(fields: \"id\") {\n id: Int! @external\n name: String! @external\n}\n\nextend type Query {\n episodes: [Episode!]! \n deprecatedEpisodes: [Episode!]! @deprecated(reason: \"Because you should use the other one.\") \n}\n"