muuki88 / sbt-graphql

SBT plugin to generate and validate graphql schemas written with Sangria
Apache License 2.0
95 stars 20 forks source link

Generate code from schemas #19

Open ksajme opened 6 years ago

ksajme commented 6 years ago

It would be very useful to be able to leverage code generation to make case classes for a Sangria server with an SDL/IDL schema (within a .graphql file, Sangria calls this schema materialization).

Is that a feasible feature addition based on the code generation code being added to this project?

muuki88 commented 6 years ago

Hi @ksajme Thanks for your suggestion. This sounds like a proper use case to me. Just to be clear that I don't get this wrong:

You have a pre-existing schema defined as SDL/IDL file. Next you want to implement this schema. Normally you would have to implement the case classes your own, but you would like to generate them from the SDL.

I haven't looked at the schema materialisation feature in depth yet, but your suggestion sounds perfect for this plugin.

ksajme commented 6 years ago

Yes, that's exactly it.

The use case is for GraphQL servers. Sangria provides macros to generate case classes if you are using its DSL but if you are using an SDL/IDL schema file as a source (materialization), you are out in the cold.

I'd be curious to see if the code @jonas is working on could be modified to fit this purpose without much fuss.