Skip to content

Commit

Permalink
Upgrade to GraphQL Java 22 test version
Browse files Browse the repository at this point in the history
See gh-932
  • Loading branch information
bclozel committed Mar 29, 2024
1 parent 52202d4 commit 8a4a432
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 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.1.4"
graphQlJavaVersion = "0.0.0-2024-03-20T00-25-33-974c165"
graphQlJavaVersion = "0.0.0-2024-03-28T10-27-26-41c9ba2"
springBootVersion = "3.2.2"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
import java.util.function.Function;

import graphql.schema.DataFetcher;
import graphql.schema.FieldCoordinates;
import graphql.schema.GraphQLCodeRegistry;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLFieldsContainer;
Expand Down Expand Up @@ -78,7 +79,8 @@ public TraversalControl visitGraphQLFieldDefinition(
if (dataFetcher != null) {
GraphQLCodeRegistry.Builder registry = context.getVarFromParents(GraphQLCodeRegistry.Builder.class);
if (!hasDataFetcher(registry, parent, fieldDefinition)) {
registry.dataFetcher(parent, fieldDefinition, dataFetcher);
FieldCoordinates coordinates = FieldCoordinates.coordinates(parent.getName(), fieldDefinition.getName());
registry.dataFetcher(coordinates, dataFetcher);
}
}

Expand All @@ -101,7 +103,8 @@ private boolean hasDataFetcher(
GraphQLCodeRegistry.Builder registry, GraphQLFieldsContainer parent,
GraphQLFieldDefinition fieldDefinition) {

DataFetcher<?> fetcher = registry.getDataFetcher(parent, fieldDefinition);
FieldCoordinates coordinates = FieldCoordinates.coordinates(parent.getName(), fieldDefinition.getName());
DataFetcher<?> fetcher = registry.getDataFetcher(coordinates, fieldDefinition);
return (fetcher != null && !(fetcher instanceof PropertyDataFetcher));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
import org.springframework.lang.Nullable;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;

Expand Down Expand Up @@ -95,8 +96,8 @@ public GraphQlObservationInstrumentation(ObservationRegistry observationRegistry
}

@Override
public InstrumentationState createState(InstrumentationCreateStateParameters parameters) {
return RequestObservationInstrumentationState.INSTANCE;
public CompletableFuture<InstrumentationState> createStateAsync(InstrumentationCreateStateParameters parameters) {
return CompletableFuture.completedFuture(RequestObservationInstrumentationState.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -119,7 +119,7 @@ void retrieveWithOperationNameAndVariables() {
void retrieveInvalidResponse() {

String document = "errorsOnlyResponse";
getGraphQlService().setErrors(document, new ValidationError(ValidationErrorType.InvalidSyntax));
getGraphQlService().setErrors(document, ValidationError.newValidationError().validationErrorType(ValidationErrorType.InvalidSyntax).build());
testRetrieveFieldAccessException(document, "me");

document = "nullDataResponse";
Expand Down Expand Up @@ -162,7 +162,7 @@ private void testRetrieveFieldAccessException(String document, String path) {
void executeInvalidResponse() {

String document = "errorsOnlyResponse";
getGraphQlService().setErrors(document, new ValidationError(ValidationErrorType.InvalidSyntax));
getGraphQlService().setErrors(document, ValidationError.newValidationError().validationErrorType(ValidationErrorType.InvalidSyntax).build());
testExecuteFailedResponse(document);

document = "nullDataResponse";
Expand Down

0 comments on commit 8a4a432

Please sign in to comment.