-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fragment code generation is broken for union types #76
Comments
Hello @muuki88! Thank you for writing this excellent plugin! I am using it to generate the client code for a project and I am running into some problems related to this issue. Reproducing the issueThis issue occurs with the Apollo codegen style.
The query is
The compile error is
The problem is that the generated code should be
but instead it is
Here is the full generated code: Click to expand!
I believe the problem also occurs in the unit tests here: https://github.com/muuki88/sbt-graphql/compare/issue-76/fix-fragment-union-codegen#diff-045de0b210c8e206e71c3ab7f73d3bf9b84f88653bdf74bb2c2cfb949b7a75f0R9
instead? Possible Short-Term WorkaroundsThis issue does not occur with the Sangria codegen style. The generated code is Click to expand!
which compiles successfully. However, I was wondering whether you could provide an example of generating the request body with the Sangria style since there is no Sangria The other possible workaround is to write the problematic class by hand using the Questions
Thanks! |
Hi @ellenlight Thanks for your detailed and comprehensive issue report TL;DR Sangria StyleThe sangria style code generation was the initial implementation from Jonas from another plugin. What is causing the compilation errorUnion types and fragments are quite tricky to get right in the code generation. I spent several hours to find a way to implement this, but without success so far. Any help is welcome as this project is purely maintained in my freetime (and the one of others I assume) 🤗 This is also the reason |
Sounds good and thank you for the quick reply! |
The code generation for fragments produced invalid / not compilable scala code.
Example schema and query
A simple schema with a union type
The animal fragments
And use the fragment
Expected code
The fragment and query should generate the following types in the
Interfaces.scala
And the query object code should use these types
Complexities
DogName
is defined in theInterfaces.scala
and in theGetAnimals$GetAnimals
objectdecoder
/encoder
above thedata
encoder so it can find it during derivationThe text was updated successfully, but these errors were encountered: