-
Notifications
You must be signed in to change notification settings - Fork 121
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
Fragments not working with interfaces #610
Comments
There's actually a deeper bug, the subtype-specific data does not even end up in the models final response = GGetBooksData.fromJson({
"books": [
{
"__typename": "Textbook",
"title": "Textbook",
"courses": ["Math", "Science"]
},
{
"__typename": "ColoringBook",
"title": "ColoringBook",
"colors": ["Red", "Blue"]
}
]
}); final GBookFragment textbook = response!.books[0]; // is of type _$GGetBooksData_books, with no data from the type conditions |
@knaeckeKami have you an idea on how we can fix this issue? Is it an issue from ferry or from another package? |
It's an issue in the code generation in gql_code_builder. I didn't have time to look into this bug specifically yet. It might be an issue in the |
FWIW this seems to only happen when fragments are nested. So as a workaround you could try to flatten the query. |
@nhannah Pretty sure this is the issue you were talking about 👀 |
Hi, I had some time to look into the issue. I don't know what is really causing the issue, but I came up with what should like the |
Cool! I think there is something what with the |
@bestdan this is the issue we are seeing today |
When I create a Fragment with a type which is an interface, or has fields which are interfaces, the generated code does not work at runtime.
For example let's have this schema:
And this query:
These parameters are set on build.yaml:
When we generate the code, we can see that nothing implements
GBookFragment__asTextbook
, yet we have this kind of generted code:Since nothing implements
GBookFragment__asTextbook
, the cast(this as GBookFragment__asTextbook)
will fail.Is there a workaround for that?
The text was updated successfully, but these errors were encountered: