-
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
useFragment_experimental feedback #10650
Comments
I too would like to see a further discussion of around Apollo's architectural take on query composition via fragments which can be colocated on components. Should Apollo ship a build-time tool like Relay? |
Hi @adamesque 👋 Thanks for taking the time to share this feedback! We've been discussing and considering these ideas, so we appreciate your patience here. I'll take each point individually:
|
Any idea if this discussion ended up happening anywhere? The docs seem unclear about whether this is possible with the current implementation of |
You might be interested in #11666 which reveals some info about the team's intentions re: colocated fragments |
Hi folks, wanted to provide some feedback on Apollo Client (JS)'s
useFragment_experimental
hook after we've played with it a little.returnPartialData
defaults totrue
but doesn’t wrap the return type inPartial<TData>
which means our consuming code isn’t type-safe anymore. We could do this manually at call sites but it’s a potential footgun.returnPartialData
isfalse
to be very unergonomic since wrapping a hook in try/catch violates the rule against conditional hook execution (at least as far as linters are concerned). Instead,useFragment
should return{ data: null, complete: false, missing: MissingTree }
or a classic{data, loading, error}
tuple likeuseQuery
, potentially governed by an error policy (this might be overkill though). Speaking of which…loading
flag tracking whether the requested fragment is included in a query that is also currently loading. Ideally this would be paired with auseSuspenseFragment
which would suspend while a parent query is loading / before data is available.useFragment
hook currently performs automatic query refetches via a query/fragment registration scheme. This isn’t necessarily something that should be part of a core fragment API, but we believe Relay’s cache may better handle these scenarios. Might not be solvable with a completely normalized cache, and we're exploring solutions to help ensure thatid
or key fields are always selectedI was glad to see some community discussion around fragments surface this weekend, and like I've commented in the past, it would be great to have fragment-first alternatives to Relay out there in the ecosystem, so I'm excited to see where this is headed. Thanks for all your work on this feature!
The text was updated successfully, but these errors were encountered: