2

I was looking into Spring GraphQL and I found out about the new annotation model for GraphQLControllers. I was wondering how the intended workflow for this new feature would look like regarding the creation of schema.grapqls files.

Do I have to manually create a schema.grapqls file and write the corresponding Controller(s) for its queries? Or is there some way to automatically create a schema.graphql file from the information provided by my Controllers? It would seem to me that all the necessary information to create the schema is defined by my Controllers.

Having to manually define the schema in addition to the controllers comes with some headaches, mainly regarding typos and changing/refactoring of models, since there is no compile-time connection between my controller and my schema.grapqls file.

Also, this blogpost says to post general questions about Spring GraphQL using the spring-graphql tag. However, that tag does not exists yet / I could not find it.

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
cgaisl
  • 21
  • 3

1 Answers1

0

In general, Spring GraphQL has a "schema first" approach, where developers are expected to carefully design a GraphQL schema (types, operations and embedded documentation) as this will be the main contract that client developers will use. There is no support out of the box for automatic generation from controllers, as any code change could result in an incompatible change on the schema itself, breaking existing clients.

While there is no compile time connection between controllers and the schema, the team is working on a runtime feature that would check at startup for typos and implementation errors.

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176