You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useFragment accepts a generic type, but it converts it into a DeepPartialObject. what is the best usage in here to avoid using DeepPartialObject?
#11701
Closed
paolojulian opened this issue
Mar 19, 2024
· 5 comments
We have just started implementing useFragment. But the problem is we need to add typeguard of use typecast for the DeepPartialObject. useQuery is not doing this.
The text was updated successfully, but these errors were encountered:
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}
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.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.
We have just started implementing useFragment. But the problem is we need to add typeguard of use typecast for the DeepPartialObject. useQuery is not doing this.
The text was updated successfully, but these errors were encountered: