Skip to content

Commit

Permalink
Forward compatibility with GraphQL Java 21
Browse files Browse the repository at this point in the history
Closes gh-974
  • Loading branch information
rstoyanchev committed May 20, 2024
1 parent 33bdea9 commit 6d9a8a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description = "Spring for GraphQL"
ext {
moduleProjects = [project(":spring-graphql"), project(":spring-graphql-test")]
springFrameworkVersion = "6.0.18"
graphQlJavaVersion = "20.9"
graphQlJavaVersion = "21.5"
springBootVersion = "3.1.5"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import graphql.relay.Edge;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.FieldCoordinates;
import graphql.schema.GraphQLCodeRegistry;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLFieldsContainer;
Expand Down Expand Up @@ -85,7 +86,8 @@ public TraversalControl visitGraphQLFieldDefinition(
GraphQLCodeRegistry.Builder codeRegistry = context.getVarFromParents(GraphQLCodeRegistry.Builder.class);

GraphQLFieldsContainer parent = (GraphQLFieldsContainer) context.getParentNode();
DataFetcher<?> dataFetcher = codeRegistry.getDataFetcher(parent, fieldDefinition);
FieldCoordinates fieldCoordinates = FieldCoordinates.coordinates(parent, fieldDefinition);
DataFetcher<?> dataFetcher = codeRegistry.getDataFetcher(fieldCoordinates, fieldDefinition);

if (visitorHelper != null && isUnderSubscriptionOperation(visitorHelper, context)) {
return TraversalControl.CONTINUE;
Expand All @@ -101,7 +103,7 @@ public TraversalControl visitGraphQLFieldDefinition(
}
else {
dataFetcher = new ConnectionDataFetcher(dataFetcher, this.adapter);
codeRegistry.dataFetcher(parent, fieldDefinition, dataFetcher);
codeRegistry.dataFetcher(fieldCoordinates, dataFetcher);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import graphql.GraphQLContext;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.FieldCoordinates;
import graphql.schema.GraphQLCodeRegistry;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLFieldsContainer;
Expand Down Expand Up @@ -139,12 +140,13 @@ public TraversalControl visitGraphQLFieldDefinition(
GraphQLCodeRegistry.Builder codeRegistry = context.getVarFromParents(GraphQLCodeRegistry.Builder.class);

GraphQLFieldsContainer parent = (GraphQLFieldsContainer) context.getParentNode();
DataFetcher<?> dataFetcher = codeRegistry.getDataFetcher(parent, fieldDefinition);
FieldCoordinates fieldCoordinates = FieldCoordinates.coordinates(parent, fieldDefinition);
DataFetcher<?> dataFetcher = codeRegistry.getDataFetcher(fieldCoordinates, fieldDefinition);

if (applyDecorator(dataFetcher)) {
boolean handlesSubscription = visitorHelper.isSubscriptionType(parent);
dataFetcher = new ContextDataFetcherDecorator(dataFetcher, handlesSubscription, this.exceptionResolver);
codeRegistry.dataFetcher(parent, fieldDefinition, dataFetcher);
codeRegistry.dataFetcher(fieldCoordinates, dataFetcher);
}

return TraversalControl.CONTINUE;
Expand Down

0 comments on commit 6d9a8a2

Please sign in to comment.