From 8a4a4327e10467b22b303bf6f752b1e9621ee739 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 29 Mar 2024 18:59:32 +0100 Subject: [PATCH] Upgrade to GraphQL Java 22 test version See gh-932 --- build.gradle | 2 +- .../graphql/data/query/AutoRegistrationTypeVisitor.java | 9 ++++++--- .../observation/GraphQlObservationInstrumentation.java | 5 +++-- .../graphql/client/GraphQlClientTests.java | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 1aa0ac422..c6857904f 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/query/AutoRegistrationTypeVisitor.java b/spring-graphql/src/main/java/org/springframework/graphql/data/query/AutoRegistrationTypeVisitor.java index fe1c1ade3..a2d18ca45 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/query/AutoRegistrationTypeVisitor.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/query/AutoRegistrationTypeVisitor.java @@ -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. @@ -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; @@ -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); } } @@ -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)); } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/observation/GraphQlObservationInstrumentation.java b/spring-graphql/src/main/java/org/springframework/graphql/observation/GraphQlObservationInstrumentation.java index 854bd96e5..65a4af6ae 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/observation/GraphQlObservationInstrumentation.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/observation/GraphQlObservationInstrumentation.java @@ -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; @@ -95,8 +96,8 @@ public GraphQlObservationInstrumentation(ObservationRegistry observationRegistry } @Override - public InstrumentationState createState(InstrumentationCreateStateParameters parameters) { - return RequestObservationInstrumentationState.INSTANCE; + public CompletableFuture createStateAsync(InstrumentationCreateStateParameters parameters) { + return CompletableFuture.completedFuture(RequestObservationInstrumentationState.INSTANCE); } @Override diff --git a/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java b/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java index b47b0c26e..3545ee748 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java @@ -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. @@ -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"; @@ -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";