We’re leveraging TanStack Router and are realy loving the ability to kick off an Apollo request outside of React, but we ran into an interesting issue where we need to conditionally call a preloadQuery which presents more of a problem when it gets down to the useReadQuery because we need to add extra layers since the useReadQuery will blow up without a proper ref. Is there a best practice for these situations or a concept of a skip ref
that we can pass so that it returns null without blowing up.
Thanks!
Hey @ericchernuka 
We don’t have support for anything like that in useReadQuery
right now. Generally we recommend rendering the component conditionally and splitting out a separate placeholder-type component for the case that you need to show some fallback content in those cases you aren’t fetching anything.
Sounds good. Ya we figured as much after reading a few GitHub issues, but thought I’d ask. We ended up with a <ConditionalPreloadQuery ref render />
where internally the ref is either resolved or not and passed back to the render function with null or data. We can then decide to wrap it in a ErrorBoundary and/or Suspense depending on the need. Simple, yet flexible.
Thanks for the quick response.
1 Like