Comments (4)
Hey @paolojulian 👋
This happens because we don't know if the cache can fulfill the entirety of the fragment
or not. useFragment
will return any data it can, therefore it can be partial. useFragment
also returns a complete
property that you can use to determine if the cache could fulfill the entire fragment. The types will adjust to the non-partial type if you check for complete
first.
const { complete, data } = useFragment<MyFragment>({ fragment })
// ^? DeepPartial<MyFragment>
if (complete) {
data
// ^? MyFragment
}
Hope this helps!
from apollo-client.
@jerelmiller
Ahhh, I wonder why I didn't notice it 😅 , i was also looking at the useFragment.d.ts but didn't catch it, thanks for this!
from apollo-client.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
from apollo-client.
You're welcome! Glad I could help 🙂
from apollo-client.
Related Issues (20)
- [Data masking] Create guide on integrating data masking with GraphQL Codegen
- `useQuery` API documentation anchor links are all `#undefined` HOT 3
- `useFragment`, returns false data. HOT 6
- Pagination using useSuspenseQuery gets empty array instead of cached array when api response with empty array HOT 4
- Merging array in DeepMerger HOT 3
- RFC: Schema-driven testing HOT 2
- Infer `connectToDevTools` regardless of whether another client has connected or not
- startTransition has no affect on refetch or fetchMore with errorPolicy: 'all' HOT 3
- [Testing utilities] Example with MSW HOT 1
- [Testing utilities] Custom fetch implementation via context HOT 4
- [Testing utilities] Performance test against a large schema HOT 2
- Again, onCompleted is not called when useLazyQuery HOT 6
- Any callback function on a global level or in a mutation to collect optimistic response failures? HOT 6
- refetch from useSuspenseQuery doesn`t return the updated data with fetchPolicy: 'cache-first' HOT 3
- Issue with useSuspenseQuery in Next.js Client Component: Duplicate Queries on Server and Client HOT 6
- @client on arguments HOT 9
- [Docs] Add some documentation on how to test `preloadQuery`
- [Data masking] Provide testing utility to provide proper format to `from` option in `useFragment`
- Typescript error with RequestInfo HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client.