-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Query containing only fragments does not work #3402
Comments
Declare your |
That did not work. I'm now using this and it does not work:
|
According to the GraphQL spec:
So the correct way to write your fragment above is like this:
where the peopleFrag is a fragment of the type Person. |
My peopleFrag is a fragment on Query, which, from my understanding, is a type. So it seems I am adhering to the GraphQL spec. Or am I mistaken? |
I think you're definitely right, Query is an object type! I tried doing some research on other code and havent ever seen a fragment |
Wow! This looks like it might be quite an oversight, but it should definitely work! |
Assigning this to myself. So i indeed reproduce this error in the error template project. I do not reproduce this in apollo dev tools querying from graphiql. I also tried to write a failing test for this in AC, but nothing fails. So I'm going to look at react apollo next and report back. |
Awesome! Thanks for looking into it :) |
Here is a PR in React apollo that demonstrates the failure apollographql/react-apollo#1987 One test is to verify that my understanding of |
@abhiaiyer91 weird, so it's a react-apollo issue somehow? |
@stubailo Looks like it, im gonna work on this tomorrow and figure out why its broken |
This is actually an apollo-client bug. And ill have some code to address this soon. |
The reason this happens is when AC attempts to make a query that has a selection set with a What we want to have happen here is when we do the diff when fetching queries we need to mark the context as missing fields: https://github.com/apollographql/apollo-client/blob/master/packages/apollo-cache-inmemory/src/readFromStore.ts#L125 which right now it is coming back as false. Going deeper there, the reason we arent executing this right now is because our selection set only has a fragment, and if youre using the Heuristic fragment matcher it doesnt attempt to resolve sub fields in the fragment when the only root id is ROOT_QUERY This fixes the issue #3484 |
Currently seeing this issue. Are there any plans to fix this? |
I also have this same issue. Using apollo-boost 0.1.15. This should definitely work right? |
@BrentLayne this CodeSandbox shows the same issue. If you update the cache package to |
It seems like this issue is still present ( The fix added a check here for @abhiaiyer91 would your fix also work for |
I am testing out |
Experiencing the same on |
Is there any plan to fix this? It seems to me like a pretty serious issue resulting in unexpected bugs that are extremely difficult to trace. Appreciate any help here! :) |
Anyone please provide fix for this issue I am also facing the same. |
My issue is that it doesn't see a second fragment that I created, saying the fragment doesn't exist.
Maybe it's a little less performant, but it works. |
Intended outcome:
Trying to query using fragments, using a query like:
Actual outcome:
The query never gets sent to the graphql server
How to reproduce the issue:
I reproduced this using the react-apollo-error-template. Just replace the query in App.js with:
If you uncomment the three lines above, the query will work.
Version
The text was updated successfully, but these errors were encountered: