Skip to content
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

[Data masking] Conditionally suspend useFragment depending on source of query #11680

Closed
jerelmiller opened this issue Mar 14, 2024 · 3 comments
Closed
Labels
🎭 data-masking Issues/PRs related to data masking
Milestone

Comments

@jerelmiller
Copy link
Member

useFragment should only suspend if used with a suspenseful hook (e.g. useSuspenseQuery). If it originates from useQuery, we should not suspend.

We will need to determine if we need to provide a loading or pending field in the event it is used with useQuery. If so, this field should not be available when used with useSuspenseQuery.

@jerelmiller jerelmiller added this to the Data masking milestone Mar 14, 2024
@alessbell alessbell added the 🎭 data-masking Issues/PRs related to data masking label Jun 7, 2024
@jerelmiller
Copy link
Member Author

Discussing this further with the team, we believe this might cause too much confusion, so we aren't planning to pursue this at the moment.

If implemented, this would mean that useFragment would have different behavior depending on its surrounding environment. Determining whether a fragment would suspend or not means traversing the React tree to find the query that produced the data to see if that query is a suspenseful query or not. We believe this has too much unpredictability.

Instead, we plan to add a suspensePolicy option (or something like it) that would allow someone to determine whether to suspend on missing/pending fragment data. This would allow us to provide better type support and behave more predictably, regardless of where the query originated.

@jerelmiller jerelmiller closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
Copy link
Contributor

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.

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🎭 data-masking Issues/PRs related to data masking
Projects
None yet
Development

No branches or pull requests

2 participants