From 7eb155d76dffe098faefe98e2e78a924588498e7 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 19 Mar 2024 11:36:57 +0100 Subject: [PATCH 1/2] Upgrade to GraphQL Java 20.8 Closes gh-40020 --- .../graphql/GraphQlAutoConfiguration.java | 11 +++-------- .../graphql/GraphQlAutoConfigurationTests.java | 7 +++---- .../spring-boot-dependencies/build.gradle | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java index 37a2b97c409b..f23bc8a2aedb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-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. @@ -24,8 +24,7 @@ import graphql.GraphQL; import graphql.execution.instrumentation.Instrumentation; -import graphql.schema.idl.RuntimeWiring.Builder; -import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility; +import graphql.introspection.Introspection; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -102,7 +101,7 @@ public GraphQlSource graphQlSource(ResourcePatternResolver resourcePatternResolv .subscriptionExceptionResolvers(subscriptionExceptionResolvers.orderedStream().toList()) .instrumentation(instrumentations.orderedStream().toList()); if (!properties.getSchema().getIntrospection().isEnabled()) { - builder.configureRuntimeWiring(this::enableIntrospection); + Introspection.enabledJvmWide(false); } builder.configureTypeDefinitions(new ConnectionTypeDefinitionConfigurer()); wiringConfigurers.orderedStream().forEach(builder::configureRuntimeWiring); @@ -110,10 +109,6 @@ public GraphQlSource graphQlSource(ResourcePatternResolver resourcePatternResolv return builder.build(); } - private Builder enableIntrospection(Builder wiring) { - return wiring.fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY); - } - private Resource[] resolveSchemaResources(ResourcePatternResolver resolver, String[] locations, String[] extensions) { List resources = new ArrayList<>(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java index 2719747656e1..4d935591da6c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-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. @@ -21,12 +21,12 @@ import graphql.GraphQL; import graphql.execution.instrumentation.ChainedInstrumentation; import graphql.execution.instrumentation.Instrumentation; +import graphql.introspection.Introspection; import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLOutputType; import graphql.schema.GraphQLSchema; import graphql.schema.idl.RuntimeWiring; import graphql.schema.visibility.DefaultGraphqlFieldVisibility; -import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; @@ -170,8 +170,7 @@ void shouldDisableFieldIntrospection() { this.contextRunner.withPropertyValues("spring.graphql.schema.introspection.enabled:false").run((context) -> { GraphQlSource graphQlSource = context.getBean(GraphQlSource.class); GraphQLSchema schema = graphQlSource.schema(); - assertThat(schema.getCodeRegistry().getFieldVisibility()) - .isInstanceOf(NoIntrospectionGraphqlFieldVisibility.class); + assertThat(Introspection.isEnabledJvmWide()).isFalse(); }); } diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 612133649f76..531834395b52 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -320,7 +320,7 @@ bom { ] } } - library("GraphQL Java", "20.2") { + library("GraphQL Java", "20.8") { group("com.graphql-java") { modules = [ "graphql-java" From dc2c253a452a74a7fa8a49a0850d14b85749152f Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 19 Mar 2024 11:38:37 +0100 Subject: [PATCH 2/2] Upgrade to GraphQL Java 21.4 Closes gh-40021 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 50849177e2b2..256d51b59a5c 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -328,7 +328,7 @@ bom { ] } } - library("GraphQL Java", "21.3") { + library("GraphQL Java", "21.4") { prohibit { startsWith(["2018-", "2019-", "2020-", "2021-", "230521-"]) because "These are snapshots that we don't want to see"