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
useFragment #1510
Labels
Comments
Does this feature exist in @apollo/client ? |
Yes, see: https://www.apollographql.com/docs/react/api/react/hooks/#usefragment (@apollo/client 3.8.0+) And source code: https://github.com/apollographql/apollo-client/blob/a8fe0a1217d9784d3165e0ec2e88a2caca0f82d7/src/react/hooks/useFragment.ts#L44-L92 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
I wanted to get a specific object from the cache that I knew would exist (because another query loading all objects of that type). Somehow graphQL (or useQuery) was not smart enough to resolve this object from cache via a normal useQuery. So I started reading the Apollo documentation and the useFragment hook they have https://www.apollographql.com/docs/react/api/react/hooks#usefragment sounded perfect! As in, just give me the data we have for a specific object.
Describe the solution you'd like
"Native" reactive useFragment method.
Describe alternatives you've considered
I ended up implementing a quick useFragment that gets the job done, but not more than that.
Additional context
The text was updated successfully, but these errors were encountered: