[schema generator] Where is the schema returning from toSchema() supposed to go? (Spring GraphQL) #1597
-
Hi! I am trying to use the schema generator to replace manually maintaining the schema file in our existing Spring Boot GraphQL module. I have tested the schema generation itself through debugging the code, and it seems to succeed in generating the schema. I just don't know how to get the GraphQL instance to pick it up. One of my thoughts was to use the GraphQLSource builder to customize the schema. But as of now I only get a MissingSchemaException when trying that. I could probably solve this by rebuilding a graphql server based on the graphql-kotlin-spring-server here, but as I only need the schema generation functionality, I was hoping it was possible to simply use my existing code with the schema generator on top. Appreciate any help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hello 👋 While you could potentially wire up TLDR it is potentially doable but most likely causes more issues than benefits. Our |
Beta Was this translation helpful? Give feedback.
-
as @dariuszkuc mentioned, technically it could be possible to reload the |
Beta Was this translation helpful? Give feedback.
-
Thanks for your clearifying answers, guys! I'll have a consideration on whether to migrate the whole thing or not. Out of curiosity, is there really a use case for usuing the schema generator on its own? Or does it only make sense to use as a part of graphql-kotlin-spring-server? |
Beta Was this translation helpful? Give feedback.
Hello 👋
spring-graphql
is a completely separate project that uses SDL first approach to load schema file and automatically map resolvers based on some annotations (e.g.@QueryMapping
/@SchemaMapping
).graphql-kotlin
follows a code first approach where code is used to define the schema which is constructed dynamically at runtime.While you could potentially wire up
graphql-kotlin
generated schema throughGraphQlSourceBuilderCustomizer
andschemaFactory
method (similar to spring-projects/spring-graphql#384) but I don't think thats a good idea - basically you would loose all the runtime wiring information provided byspring-graphql
so all your Spring annotated methods would stop working (or i…