https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
a

Aaron

05/30/2020, 8:13 AM
Hi everyone, has anyone encounter an issue with
spring-devtool
and
graphql-kotlin-spring-server
when hot-swapping code? The full detail is here https://github.com/ExpediaGroup/graphql-kotlin/issues/730. Essentially it would work fine the first time around, but after you make some changes or just add a simple
println
I get this error
DataFetchingException: Object is not an instance of declaring class
. Would love to know if anyone encounter this and know how to fix this 🙂
d

Dariusz Kuc

05/30/2020, 1:18 PM
You could also try asking in #spring
s

Shane Myrick

05/30/2020, 7:42 PM
I don’t know what the error is for sure, but it sounds like graphql-java may be checking the class hash to verify the output is matching the schema and the reload of the classes does not reload the
GraphQL
class to check the class hash again. I am not familiar with
spring-devtool
but can you have it also reload the spring bean for
GraphQL
when you reload the server?
a

Aaron

05/30/2020, 11:21 PM
I’m not sure how to make it reload the spring bean as well, because any time you make changes to it it will detect the changes in the classpath and automatically reloads the server. I will check it in the spring channel, but just curious could it be due to classloader issue where the object data is being deserialized? https://docs.spring.io/spring-boot/docs/1.5.16.RELEASE/reference/html/using-boot-devtools.html#using-boot-devtools-known-restart-limitations
d

Dariusz Kuc

06/04/2020, 2:13 PM
unsure about those annotations -> but I’d assume
@Secured
will most likely wrap underlying method in a proxy which might be causing the issue
👍 1
r

Robert

06/04/2020, 8:34 PM
Seems like spring security and graphql-Kotlin don’t play that nice. Also reactive spring security via Annotations doesn’t like Coroutines yet. AOP would work maybe. But I think implementing a custom directive + graphql context would fit best. graphql-java docs also https://www.graphql-java.com/documentation/v11/sdl-directives/ go this route
d

Dariusz Kuc

06/04/2020, 8:35 PM
yeah so while there is reactive spring security I don’t think it plays nice with GraphQL
i’d start with spring security filter but then populate the GraphQL context and use it with directives
5 Views