-
-
Notifications
You must be signed in to change notification settings - Fork 54
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 doesnt seem to work #315
Comments
Thanks for reaching out @PhiFry. The code-generator should not update your query or inline any field selections. It should, however, append the fragment to your query and send it to the server. Something like query GetAllUsers() {
users: core_users {
...userFields
}
}
fragment userFields on User {
id
display_name
} It is then up to the server to handle this appropriately. |
Thank you @budde377 for taking your time and explaining. I can see now that I missed the |
Flutter project pubspec.yaml:
We use Hasura as our GraphQL host.
We have a
core_users
table which has columns(id, display_name)
.In our
schema.graphql
file we have defined:Then for our query:
then
build_runner build
When I then call
_graphQLClient.query_GetAllUsers()
I get error message saying that "id" is null. When I breakpoint into the generated parsing function I see that the data received only consists of__typename
so of course its null.I dug even deeper to view the actual query being sent to our GraphQL host and found that the query doesnt include the fragment fields but only the fragment name like this:
I expected the query sent in the request to be this:
Removing the fragment and instead entering the fields manually in the query then everything works.
Is this the intended behaviour?
If it is then how can I get fragments to work? Do the GraphQL host need to specify the fragments?
The text was updated successfully, but these errors were encountered: