Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"errors": [
{
"message": "Cannot resolve entity with __typename 'FederatedFilm'.",
"locations": [
{
"line": 2,
"column": 5
}
],
"path": [
"_entities"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": null
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"_entities": [

]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"data": {
"_entities": [
{
"id": "RmVkZXJhdGVkRmlsbTo0"
"id": "RmVkZXJhdGVkQ3VzdG9tZXJPbmVOb25SZXNvbHZhYmxlOjg",
"firstName": "SUSAN",
"lastName": "WILSON",
"email": "SUSAN.WILSON@sakilacustomer.org"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -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
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
]
}
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ query FederationEntities($representations: [_Any!]!) {
id
}
}
... on FederatedCustomerOneNonResolvable {
id
firstName
lastName
email
}
... on FederatedFilm {
id
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[
{
"_comment": "#1 - Entity with a compound key, one type returned",
"representations": {
"__typename": "FederatedStaff",
"email": "Mike.Hillyer@sakilastaff.com",
"username": "Mike"
}
},
{
"_comment": "#2 - Entity with a compound key, two types returned",
"representations": [
{
"__typename": "FederatedStaff",
Expand All @@ -21,6 +23,7 @@
]
},
{
"_comment": "#3 - Entity with a splitQuery",
"representations": [
{
"__typename": "FederatedAddress",
Expand All @@ -29,6 +32,7 @@
]
},
{
"_comment": "#4 - Entity with two keys, both resolvable and used",
"representations": [
{
"__typename": "FederatedCustomer",
Expand All @@ -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",
Expand All @@ -69,6 +85,7 @@
]
},
{
"_comment": "#8 - Entity with a non-string key",
"representations": [
{
"__typename": "FederatedPayment",
Expand All @@ -79,6 +96,7 @@
]
},
{
"_comment": "#9 - Entity with a non-identifying key",
"representations": [
{
"__typename": "FederatedFilmActorWithBadKey",
Expand All @@ -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": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ private List<Consumer<TypeDefinitionRegistry>> getRegistryTransforms() {
private List<Function<GraphQLSchema, GraphQLSchema>> getSchemaTransforms(TypeDefinitionRegistry registry) {
var transforms = new ArrayList<Function<GraphQLSchema, GraphQLSchema>>();

// 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DirectivesFilter(GraphQLSchema schema, Set<String> directiveNamesToRemove
*/
@Override
public GraphQLSchema getModifiedGraphQLSchema() {
var generatorDirectiveVisitor = new GraphQLTypeVisitorStub() {
var visitor = new GraphQLTypeVisitorStub() {
@Override
public TraversalControl visitGraphQLDirective(GraphQLDirective node, TraverserContext<GraphQLSchemaElement> context) {
if (isExcludedDirective(node.getName())) {
Expand All @@ -39,7 +39,7 @@ public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective nod
return CONTINUE;
}
};
return SchemaTransformer.transformSchema(schema, generatorDirectiveVisitor);
return SchemaTransformer.transformSchema(schema, visitor);
}

/**
Expand Down
Loading