Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

CORS functionality cannot be disabled with property 'graphql.servlet.cors-enabled' #763

Closed
@bvklingeren

Description

@bvklingeren

Describe the bug

The GraphQLWebAutoConfiguration class contains a 'corsConfigurer' bean factory method which has a @ConditionalOnProperty annotation with the value of 'graphql.servlet.corsEnabled'. This does not match with the 'graphql.servlet.cors-enabled' config parameter which is the expected format of such a property and therefore it doesn't prevent the CorsFilter to be created when you define the 'graphql.servlet.cors-enabled' config parameter with the value 'false'.

To Reproduce
Steps to reproduce the behavior:

  1. Register config param 'graphql.servlet.cors-enabled' in e.g. application.properties with value 'false'
  2. Create a breakpoint at line 127 of GraphQLWebAutoConfiguration
  3. Start your SB app in debug mode
  4. The debugger stops at the breakpoint

Expected behavior
The breakpoint should not have been reached and therefore the CorsFilter should not have been created.

Screenshots
N/a

Desktop (please complete the following information):
N/a

Additional context
N/a

Activity

BlasiusSecundus

BlasiusSecundus commented on Dec 31, 2021

@BlasiusSecundus

This seems to be a duplicate of #682, which was already resolved (although the fix is not yet in the latest release, only in snapshot version).

bvklingeren

bvklingeren commented on Jan 3, 2022

@bvklingeren
Author

Ah yes, you're right. I'll be looking out for the new release then.

kumaritian

kumaritian commented on Aug 19, 2022

@kumaritian

The issue still exists in the spring-boot 2.7.1 version.

oliemansm

oliemansm commented on Aug 19, 2022

@oliemansm
Member

@kumaritian I've just tested this using the reproduction script of the original reporter with v13.0.0 icw Spring Boot and can confirm it is actually solved. So you must be doing something differently or are experiencing some other kind of issue.

kumaritian

kumaritian commented on Aug 19, 2022

@kumaritian

@oliemansm : In which Spring boot version the issue got resolved. Currently I am using 2.7.1 version.

oliemansm

oliemansm commented on Aug 19, 2022

@oliemansm
Member

@kumaritian It's not a specific Spring Boot version. It's resolved in graphql-spring-boot, so you need to upgrade that to v13.0.0

kumaritian

kumaritian commented on Aug 19, 2022

@kumaritian

@oliemansm : After upgrading to V13.0.0 from V12.0.0, I am getting below error during application start up but with V12.0.0 there is no issue as application is started successfully.

          <dependency>
		<groupId>com.graphql-java-kickstart</groupId>
		<artifactId>graphql-spring-boot-starter</artifactId>
		<version>13.0.0</version>
	</dependency>
	<dependency>
		<groupId>com.graphql-java-kickstart</groupId>
		<artifactId>graphql-java-tools</artifactId>
		<version>13.0.0</version>
	</dependency>

Note:

  1. With <version>12.0.0</version> the application is started successfully.

Error
java.lang.IllegalStateException: Failed to introspect Class [graphql.kickstart.autoconfigure.editor.graphiql.GraphiQLAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@22d8cfe0]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485) ~[spring-core-5.3.22.jar:5.3.22]
.....
....
....
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.2.jar:2.7.2]
at com.mt.amp.pot.service.aggregator.ServiceAggregatorApplication.main(ServiceAggregatorApplication.java:22) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/reactive/function/server/RouterFunction
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.22.jar:5.3.22]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.web.reactive.function.server.RouterFunction
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
... 25 common frames omitted

Dependencies
dependencies_in_pom xml

oliemansm

oliemansm commented on Aug 19, 2022

@oliemansm
Member

This should be a separate discussion in Q&A instead of hijacking this issue for this problem. It's not related. Remove the graphql-java-tools dependency. graphql-spring-boot-starter pulls in the correct version.

kumaritian

kumaritian commented on Aug 19, 2022

@kumaritian

@oliemansm : Thanks for the input and I did removed graphql-java-tools and tried it but still the same error :(

oliemansm

oliemansm commented on Aug 19, 2022

@oliemansm
Member

Open a separate discussion for this to get further assistance.

kumaritian

kumaritian commented on Aug 19, 2022

@kumaritian

@oliemansm : Thanks for your support. FYI : I have created a new issue #856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bvklingeren@oliemansm@BlasiusSecundus@kumaritian

        Issue actions

          CORS functionality cannot be disabled with property 'graphql.servlet.cors-enabled' · Issue #763 · graphql-java-kickstart/graphql-spring-boot