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
Description
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:
- Register config param 'graphql.servlet.cors-enabled' in e.g. application.properties with value 'false'
- Create a breakpoint at line 127 of GraphQLWebAutoConfiguration
- Start your SB app in debug mode
- 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 commentedon Dec 31, 2021
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 commentedon Jan 3, 2022
Ah yes, you're right. I'll be looking out for the new release then.
kumaritian commentedon Aug 19, 2022
The issue still exists in the spring-boot 2.7.1 version.
oliemansm commentedon Aug 19, 2022
@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 commentedon Aug 19, 2022
@oliemansm : In which Spring boot version the issue got resolved. Currently I am using 2.7.1 version.
oliemansm commentedon Aug 19, 2022
@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 commentedon Aug 19, 2022
@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.
Note:
<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

oliemansm commentedon Aug 19, 2022
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 commentedon Aug 19, 2022
@oliemansm : Thanks for the input and I did removed
graphql-java-tools
and tried it but still the same error :(oliemansm commentedon Aug 19, 2022
Open a separate discussion for this to get further assistance.
kumaritian commentedon Aug 19, 2022
@oliemansm : Thanks for your support. FYI : I have created a new issue #856