diff --git a/graphitron-codegen-parent/graphitron-java-codegen/src/main/java/no/sikt/graphitron/definitions/objects/RecordObjectDefinition.java b/graphitron-codegen-parent/graphitron-java-codegen/src/main/java/no/sikt/graphitron/definitions/objects/RecordObjectDefinition.java index 9a87577c3..4484c4ae1 100644 --- a/graphitron-codegen-parent/graphitron-java-codegen/src/main/java/no/sikt/graphitron/definitions/objects/RecordObjectDefinition.java +++ b/graphitron-codegen-parent/graphitron-java-codegen/src/main/java/no/sikt/graphitron/definitions/objects/RecordObjectDefinition.java @@ -63,7 +63,7 @@ public RecordObjectDefinition(T objectDefinition) { requiredInputs = hasTable() ? getRequiredFields(getTable().getMappingName()).stream().map(String::toUpperCase).collect(Collectors.toCollection(LinkedHashSet::new)) : new LinkedHashSet<>(); inputsSortedByNullability = sortInputsByNullability(); hasKeys = objectDefinition.hasDirective(FEDERATION_KEY.getName()); - keys = hasKeys ? FederationFieldSet.fromString(getRepeatableDirectiveArgumentString(objectDefinition, FEDERATION_KEY.getName(), FEDERATION_KEY_ARGUMENT.getName())) : null; + keys = hasKeys ? FederationFieldSet.fromString(getRepeatableDirectiveArgumentString(objectDefinition, FEDERATION_KEY.getName(), FEDERATION_KEY_FIELDS.getName())) : null; isFederationExternal = objectDefinition.hasDirective(FEDERATION_EXTERNAL.getName()); hasNodeDirective = objectDefinition.hasDirective(NODE.getName()); diff --git a/graphitron-common/src/main/java/no/sikt/graphql/naming/GraphQLReservedName.java b/graphitron-common/src/main/java/no/sikt/graphql/naming/GraphQLReservedName.java index 6d9f6e7dc..a9ff3ad2e 100644 --- a/graphitron-common/src/main/java/no/sikt/graphql/naming/GraphQLReservedName.java +++ b/graphitron-common/src/main/java/no/sikt/graphql/naming/GraphQLReservedName.java @@ -48,7 +48,8 @@ public enum GraphQLReservedName { OPERATION_MUTATION(uncapitalize(SCHEMA_MUTATION.getName())), FEDERATION_KEY(FederationDirectives.keyName), - FEDERATION_KEY_ARGUMENT(FederationDirectives.fieldsArgumentName), + FEDERATION_KEY_FIELDS(FederationDirectives.fieldsArgumentName), + FEDERATION_KEY_RESOLVABLE("resolvable"), FEDERATION_LINK("link"), FEDERATION_LINK_IMPORT("import"), FEDERATION_TAG("tag"), diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation-entities-invalid-4.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation-entities-invalid-4.result.approved.json new file mode 100644 index 000000000..2c937cb66 --- /dev/null +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation-entities-invalid-4.result.approved.json @@ -0,0 +1,20 @@ +{ + "errors": [ + { + "message": "Cannot resolve entity with __typename 'FederatedFilm'.", + "locations": [ + { + "line": 2, + "column": 5 + } + ], + "path": [ + "_entities" + ], + "extensions": { + "classification": "DataFetchingException" + } + } + ], + "data": null +} \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-10.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-10.result.approved.json index bb844e4a8..78fa0a4e1 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-10.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-10.result.approved.json @@ -1,7 +1,19 @@ { "data": { "_entities": [ - + { + "id": "RmVkZXJhdGVkU3RhZmY6MQ", + "email": "Mike.Hillyer@sakilastaff.com", + "username": "Mike" + }, + { + "id": "RmVkZXJhdGVkQWRkcmVzczox", + "addressLine1": "47 MySakila Drive", + "zip": null, + "city": { + "id": "Q2l0eVR5cGU6MzAw" + } + } ] } } \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-11.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-11.result.approved.json new file mode 100644 index 000000000..bb844e4a8 --- /dev/null +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-11.result.approved.json @@ -0,0 +1,7 @@ +{ + "data": { + "_entities": [ + + ] + } +} \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-3.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-3.result.approved.json index 599ac544b..642a1d379 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-3.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-3.result.approved.json @@ -11,4 +11,4 @@ } ] } -} +} \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-4.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-4.result.approved.json index a70d9afc6..375435c9b 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-4.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-4.result.approved.json @@ -21,4 +21,4 @@ } ] } -} +} \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-5.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-5.result.approved.json index fdf115754..80b738a39 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-5.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-5.result.approved.json @@ -2,8 +2,11 @@ "data": { "_entities": [ { - "id": "RmVkZXJhdGVkRmlsbTo0" + "id": "RmVkZXJhdGVkQ3VzdG9tZXJPbmVOb25SZXNvbHZhYmxlOjg", + "firstName": "SUSAN", + "lastName": "WILSON", + "email": "SUSAN.WILSON@sakilacustomer.org" } ] } -} +} \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-6.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-6.result.approved.json index 684f228eb..ce7dc12aa 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-6.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-6.result.approved.json @@ -1,17 +1,7 @@ { "data": { "_entities": [ - { - "id": "RmVkZXJhdGVkU3RhZmY6MQ", - "email": "Mike.Hillyer@sakilastaff.com", - "username": "Mike" - }, - null, - { - "id": "RmVkZXJhdGVkU3RhZmY6MQ", - "email": "Mike.Hillyer@sakilastaff.com", - "username": "Mike" - } + null ] } } \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-7.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-7.result.approved.json index 8dffc8ff8..684f228eb 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-7.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-7.result.approved.json @@ -2,9 +2,15 @@ "data": { "_entities": [ { - "amount": 0.99, - "dateTime": "2005-05-28T10:35:23", - "paymentId": 2 + "id": "RmVkZXJhdGVkU3RhZmY6MQ", + "email": "Mike.Hillyer@sakilastaff.com", + "username": "Mike" + }, + null, + { + "id": "RmVkZXJhdGVkU3RhZmY6MQ", + "email": "Mike.Hillyer@sakilastaff.com", + "username": "Mike" } ] } diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-8.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-8.result.approved.json index a00ef13b3..8dffc8ff8 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-8.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-8.result.approved.json @@ -1,20 +1,11 @@ { - "errors": [ - { - "message": "An exception occurred. The error has been logged with id [UUID]: Key {actorId=1, __typename=FederatedFilmActorWithBadKey} is not unique in Result", - "locations": [ - { - "line": 2, - "column": 5 - } - ], - "path": [ - "_entities" - ], - "extensions": { - "classification": "DataFetchingException" + "data": { + "_entities": [ + { + "amount": 0.99, + "dateTime": "2005-05-28T10:35:23", + "paymentId": 2 } - } - ], - "data": null + ] + } } \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-9.result.approved.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-9.result.approved.json index 78fa0a4e1..a00ef13b3 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-9.result.approved.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/approvals/query_federation_entities-9.result.approved.json @@ -1,19 +1,20 @@ { - "data": { - "_entities": [ - { - "id": "RmVkZXJhdGVkU3RhZmY6MQ", - "email": "Mike.Hillyer@sakilastaff.com", - "username": "Mike" - }, - { - "id": "RmVkZXJhdGVkQWRkcmVzczox", - "addressLine1": "47 MySakila Drive", - "zip": null, - "city": { - "id": "Q2l0eVR5cGU6MzAw" + "errors": [ + { + "message": "An exception occurred. The error has been logged with id [UUID]: Key {actorId=1, __typename=FederatedFilmActorWithBadKey} is not unique in Result", + "locations": [ + { + "line": 2, + "column": 5 } + ], + "path": [ + "_entities" + ], + "extensions": { + "classification": "DataFetchingException" } - ] - } + } + ], + "data": null } \ No newline at end of file diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation-entities-invalid.variables.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation-entities-invalid.variables.json index 65916c015..ccb08b1cc 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation-entities-invalid.variables.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation-entities-invalid.variables.json @@ -1,11 +1,23 @@ [ { + "_comment": "1 - Nonexistent type", "representations": [{"__typename": "NonExistingType"}] }, { + "_comment": "2 - Type that is not an entity", "representations": [{"__typename": "Customer"}] }, { + "_comment": "3 - No typename provided", "representations": [{}] + }, + { + "_comment": "4 - Entity has only non-resolvable keys", + "representations": [ + { + "__typename": "FederatedFilm", + "id": "RmVkZXJhdGVkRmlsbTo0" + } + ] } ] diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.graphql b/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.graphql index b25019f18..726e640f1 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.graphql +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.graphql @@ -22,6 +22,12 @@ query FederationEntities($representations: [_Any!]!) { id } } + ... on FederatedCustomerOneNonResolvable { + id + firstName + lastName + email + } ... on FederatedFilm { id } diff --git a/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.variables.json b/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.variables.json index cebb8e36e..bb40889c6 100644 --- a/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.variables.json +++ b/graphitron-example/graphitron-example-server/src/test/resources/approval/queries/query_federation_entities.variables.json @@ -1,5 +1,6 @@ [ { + "_comment": "#1 - Entity with a compound key, one type returned", "representations": { "__typename": "FederatedStaff", "email": "Mike.Hillyer@sakilastaff.com", @@ -7,6 +8,7 @@ } }, { + "_comment": "#2 - Entity with a compound key, two types returned", "representations": [ { "__typename": "FederatedStaff", @@ -21,6 +23,7 @@ ] }, { + "_comment": "#3 - Entity with a splitQuery", "representations": [ { "__typename": "FederatedAddress", @@ -29,6 +32,7 @@ ] }, { + "_comment": "#4 - Entity with two keys, both resolvable and used", "representations": [ { "__typename": "FederatedCustomer", @@ -42,14 +46,26 @@ ] }, { + "_comment": "#5 - Entity with two keys, using the resolvable one", "representations": [ { - "__typename": "FederatedFilm", - "id": "RmVkZXJhdGVkRmlsbTo0" + "__typename": "FederatedCustomerOneNonResolvable", + "id": "RmVkZXJhdGVkQ3VzdG9tZXJPbmVOb25SZXNvbHZhYmxlOjg=" } ] }, { + "_comment": "#6 - Entity with two keys, using the non-resolvable one", + "representations": [ + { + "__typename": "FederatedCustomerOneNonResolvable", + "firstName": "SUSAN", + "lastName": "WILSON" + } + ] + }, + { + "_comment": "#7 - Fetching entities where one type does not exist", "representations": [ { "__typename": "FederatedStaff", @@ -69,6 +85,7 @@ ] }, { + "_comment": "#8 - Entity with a non-string key", "representations": [ { "__typename": "FederatedPayment", @@ -79,6 +96,7 @@ ] }, { + "_comment": "#9 - Entity with a non-identifying key", "representations": [ { "__typename": "FederatedFilmActorWithBadKey", @@ -87,12 +105,14 @@ ] }, { + "_comment": "#10 - Fetching two types of entities at once", "representations": [ {"__typename": "FederatedStaff", "email": "Mike.Hillyer@sakilastaff.com", "username": "Mike"}, {"__typename": "FederatedAddress", "id": "RmVkZXJhdGVkQWRkcmVzczox"} ] }, { + "_comment": "#11 - Empty representations", "representations": [] } ] diff --git a/graphitron-example/graphitron-example-spec/src/main/resources/graphql/federation.graphql b/graphitron-example/graphitron-example-spec/src/main/resources/graphql/federation.graphql index 4c76c23ed..44249637e 100644 --- a/graphitron-example/graphitron-example-spec/src/main/resources/graphql/federation.graphql +++ b/graphitron-example/graphitron-example-spec/src/main/resources/graphql/federation.graphql @@ -32,7 +32,17 @@ type FederatedCustomer implements Node @node @table(name: "CUSTOMER") @key(field } """ -Type with a non-resolvable key. Should not resolve, but currently does, see GG-375. +Type with two keys, only one is resolvable. +""" +type FederatedCustomerOneNonResolvable implements Node @node @table(name: "CUSTOMER") @key(fields: "id") @key(fields: "firstName lastName", resolvable: false) { + id: ID! @nodeId + firstName: String! @field(name: "FIRST_NAME") + lastName: String! @field(name: "LAST_NAME") + email: String +} + +""" +Type with a non-resolvable key. """ type FederatedFilm implements Node @node @table(name: "FILM") @key(fields: "id", resolvable: false) { id: ID! @nodeId diff --git a/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/SchemaTransformer.java b/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/SchemaTransformer.java index 7d5863f63..b869f2f5f 100644 --- a/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/SchemaTransformer.java +++ b/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/SchemaTransformer.java @@ -52,9 +52,12 @@ private List> getRegistryTransforms() { private List> getSchemaTransforms(TypeDefinitionRegistry registry) { var transforms = new ArrayList>(); - // This one goes first since removing fields and types allows us to not process them in later transforms. if (config.removeExcludedElements()) { + // This one goes first since removing fields and types allows us to not process them in later transforms. transforms.add((s) -> new ElementRemovalFilter(s, DIRECTIVES_FOR_REMOVING_ELEMENTS).getModifiedGraphQLSchema()); + + // This clears out non-resolvable keys so our entity handling does not try to resolve them. + transforms.add((s) -> new KeyFilter(s).getModifiedGraphQLSchema()); } if (config.addFeatureFlags()) { diff --git a/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/DirectivesFilter.java b/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/DirectivesFilter.java index e02c23693..b0ce946cc 100644 --- a/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/DirectivesFilter.java +++ b/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/DirectivesFilter.java @@ -22,7 +22,7 @@ public DirectivesFilter(GraphQLSchema schema, Set directiveNamesToRemove */ @Override public GraphQLSchema getModifiedGraphQLSchema() { - var generatorDirectiveVisitor = new GraphQLTypeVisitorStub() { + var visitor = new GraphQLTypeVisitorStub() { @Override public TraversalControl visitGraphQLDirective(GraphQLDirective node, TraverserContext context) { if (isExcludedDirective(node.getName())) { @@ -39,7 +39,7 @@ public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective nod return CONTINUE; } }; - return SchemaTransformer.transformSchema(schema, generatorDirectiveVisitor); + return SchemaTransformer.transformSchema(schema, visitor); } /** diff --git a/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/KeyFilter.java b/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/KeyFilter.java new file mode 100644 index 000000000..066c8254d --- /dev/null +++ b/graphitron-schema-transform/src/main/java/no/fellesstudentsystem/schema_transformer/transform/KeyFilter.java @@ -0,0 +1,45 @@ +package no.fellesstudentsystem.schema_transformer.transform; + +import graphql.schema.*; +import graphql.util.TraversalControl; +import graphql.util.TraverserContext; +import static graphql.util.TraversalControl.CONTINUE; +import static no.sikt.graphql.naming.GraphQLReservedName.*; + +/** + * Removes non-resolvable {@code @key} directives. The {@code @key} directive applies to + * OBJECT and INTERFACE types only. + */ +public class KeyFilter implements ModifyingGraphQLTypeVisitor { + private final GraphQLSchema schema; + + public KeyFilter(GraphQLSchema schema) { + this.schema = schema; + } + + @Override + public GraphQLSchema getModifiedGraphQLSchema() { + var visitor = new GraphQLTypeVisitorStub() { + @Override + public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective node, TraverserContext context) { + if (!FEDERATION_KEY.getName().equals(node.getName())) { + return CONTINUE; + } + return !((boolean) node.getArgument(FEDERATION_KEY_RESOLVABLE.getName()).getValue()) ? deleteNode(context) : CONTINUE; + } + + @Override + public TraversalControl visitGraphQLDirective(GraphQLDirective node, TraverserContext context) { + if (!FEDERATION_KEY.getName().equals(node.getName())) { + return CONTINUE; + } + var argument = node.getArgument(FEDERATION_KEY_RESOLVABLE.getName()); + if (argument == null) { + return CONTINUE; + } + return Boolean.FALSE.equals(GraphQLArgument.getArgumentValue(argument)) ? deleteNode(context) : CONTINUE; + } + }; + return SchemaTransformer.transformSchema(schema, visitor); + } +} diff --git a/graphitron-schema-transform/src/test/java/no/fellesstudentsystem/schema_transformer/transform/KeyFilterTest.java b/graphitron-schema-transform/src/test/java/no/fellesstudentsystem/schema_transformer/transform/KeyFilterTest.java new file mode 100644 index 000000000..144d1629d --- /dev/null +++ b/graphitron-schema-transform/src/test/java/no/fellesstudentsystem/schema_transformer/transform/KeyFilterTest.java @@ -0,0 +1,36 @@ +package no.fellesstudentsystem.schema_transformer.transform; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class KeyFilterTest extends AbstractTest { + + private static final String BASE = "keyFilter/"; + + @Test + @DisplayName("Non-resolvable @key directive is removed from type") + void removeNonResolvableKeyFromType() { + var path = BASE + "removeNonResolvableType"; + var test = makeTestSchema(path); + var expected = makeExpectedSchema(path); + assertDirectives(new KeyFilter(test).getModifiedGraphQLSchema(), expected); + } + + @Test + @DisplayName("Only non-resolvable @key is removed when type has both resolvable and non-resolvable @key directives") + void mixedResolvability() { + var path = BASE + "mixedResolvability"; + var test = makeTestSchema(path); + var expected = makeExpectedSchema(path); + assertDirectives(new KeyFilter(test).getModifiedGraphQLSchema(), expected); + } + + @Test + @DisplayName("Non-resolvable @key directive is removed from interface") + void removeNonResolvableKeyFromInterface() { + var path = BASE + "removeNonResolvableInterface"; + var test = makeTestSchema(path); + var expected = makeExpectedSchema(path); + assertDirectives(new KeyFilter(test).getModifiedGraphQLSchema(), expected); + } +} diff --git a/graphitron-schema-transform/src/test/resources/keyFilter/mixedResolvability/expected/schema.graphql b/graphitron-schema-transform/src/test/resources/keyFilter/mixedResolvability/expected/schema.graphql new file mode 100644 index 000000000..c9a334afa --- /dev/null +++ b/graphitron-schema-transform/src/test/resources/keyFilter/mixedResolvability/expected/schema.graphql @@ -0,0 +1,11 @@ +scalar FieldSet +directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + +type Query { + a: A +} + +type A @key(fields: "id", resolvable: true) { + id: String + name: String +} diff --git a/graphitron-schema-transform/src/test/resources/keyFilter/mixedResolvability/schema/schema.graphql b/graphitron-schema-transform/src/test/resources/keyFilter/mixedResolvability/schema/schema.graphql new file mode 100644 index 000000000..486dc4c0f --- /dev/null +++ b/graphitron-schema-transform/src/test/resources/keyFilter/mixedResolvability/schema/schema.graphql @@ -0,0 +1,11 @@ +scalar FieldSet +directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + +type Query { + a: A +} + +type A @key(fields: "id", resolvable: true) @key(fields: "name", resolvable: false) { + id: String + name: String +} diff --git a/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableInterface/expected/schema.graphql b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableInterface/expected/schema.graphql new file mode 100644 index 000000000..a9f08d4a4 --- /dev/null +++ b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableInterface/expected/schema.graphql @@ -0,0 +1,14 @@ +scalar FieldSet +directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + +type Query { + a: A +} + +interface I { + id: String +} + +type A implements I { + id: String +} diff --git a/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableInterface/schema/schema.graphql b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableInterface/schema/schema.graphql new file mode 100644 index 000000000..5391b6220 --- /dev/null +++ b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableInterface/schema/schema.graphql @@ -0,0 +1,14 @@ +scalar FieldSet +directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + +type Query { + a: A +} + +interface I @key(fields: "id", resolvable: false) { + id: String +} + +type A implements I @key(fields: "id", resolvable: false) { + id: String +} diff --git a/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableType/expected/schema.graphql b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableType/expected/schema.graphql new file mode 100644 index 000000000..1c9bb0353 --- /dev/null +++ b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableType/expected/schema.graphql @@ -0,0 +1,10 @@ +scalar FieldSet +directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + +type Query { + a: A +} + +type A { + id: String +} diff --git a/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableType/schema/schema.graphql b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableType/schema/schema.graphql new file mode 100644 index 000000000..4605efc90 --- /dev/null +++ b/graphitron-schema-transform/src/test/resources/keyFilter/removeNonResolvableType/schema/schema.graphql @@ -0,0 +1,10 @@ +scalar FieldSet +directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + +type Query { + a: A +} + +type A @key(fields: "id", resolvable: false) { + id: String +}