Hey, there! I'm trying to incorporate graphql-kotl...
# graphql-kotlin
c
Hey, there! I'm trying to incorporate graphql-kotlin into an existing spring boot rest application with starter-security, starter-web, etc. I'm wondering if there's any special configuration or caveats I should know about? I've created a few root-level queries, and the schema generation works as expected, but the /graphql endpoint isn't working (404), nor is the playground.
s
There should NOT (edit) be any additional configuration to expose the routes. Do you see the server starting up successfully and logging the schema to the console? What is the exact URL you are sending operations to locally?
c
Yep, server starts and schema is logged to the console; i have my port configured to 8082, so I'm hitting http://localhost:8082/graphql with postman
i can get everything working just fine in a fresh project; I'm wondering if there are some dependencies that are stepping on each others toes? (e.g. spring security, starter-web)
i've noticed that in my fresh project, the server spins up using netty; my existing project uses tomcat; that's the only major difference I can see other than additional things like Spring Data initialization. Maybe it's security configuration, but I'm getting straight up 404s.
s
We are using Spring WebFlux, are you using
spring-starter-web-flux
? We can not support both Web MVC and WebFlux in the same server See: https://expediagroup.github.io/graphql-kotlin/docs/spring-server/spring-overview#webflux-vs-webmvc
c
that's probably the issue; I'll give that a shot, thanks
yeah, that was it; Unfortunately our security config is tied to WebMVC; I'll have to look into refactoring to use WebFlux
👍 1
s
If you have a lot of code using WebMVC you can still use the schema generator. You will just have to update the code used in
graphql-kotlin-spring-server
to work with MVC routes. We have had this question come up before so if you had a compatible ``graphql-kotlin-spring-mvc-server` package, we would be happy to share it with the community
d
Spring also provides reactive version of spring security that supports WebFlux
c
Yeah, I've been playing around with that this afternoon; I'm wondering if you guys have used that internally at all? I'm having some issues getting it to work with your library. If I return raw data classes from my Queries (as I would expect to be able to, and am in fact able to do without security enabled) and annotate the Query class or individual methods with @PreAuthorize, I get messages such as
must return an instance of org.reactivestreams.Publisher (i.e. Mono / Flux) in order to support Reactor Context
If I wrap the response in a
Mono
, I get schema validation issues I'm admittedly new to both WebFlux and your GraphQL implementation. I'm weighing it as an option against
com.graphql-java-kickstart:graphql-spring-boot-starter
, which is what my team is currently using.
d
unfortunately I haven’t it used so won’t be much help, that being said the error for
Mono
can solved by registering adapter for it (see https://expediagroup.github.io/graphql-kotlin/docs/schema-generator/execution/async-models#rxjavareactor for details)
c
👍 I'll have a look, thanks for the tip