-
Notifications
You must be signed in to change notification settings - Fork 589
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
chore: Add all screen queries to routes.tsx for prefetching #11709
chore: Add all screen queries to routes.tsx for prefetching #11709
Conversation
- Added ArtistShowsScreenQuery to ArtistShows.tsx and updated routes.tsx - Added ViewingRoomArtworkScreenQuery to ViewingRoomArtwork.tsx and updated routes.tsx - Exported screen queries for use in route definitions to enable data prefetching
@@ -33,7 +33,7 @@ export const ArtQuizResults = ({ isCalculatingResult }: { isCalculatingResult?: | |||
) | |||
} | |||
|
|||
const artQuizResultsQuery = graphql` | |||
export const ArtQuizResultsScreenQuery = graphql` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose this naming pattern because it's the one that is currently used for most queries. However, I'm open to changing it.
@@ -442,6 +492,7 @@ export const artsyDotNetRoutes = defineRoutes([ | |||
path: "/artist/:artistID/shows", | |||
name: "ArtistShows", | |||
Component: ArtistShowsQueryRenderer, | |||
queries: [ArtistShowsScreenQuery], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases like this query, we need queryVariables
as well so this would work properly. So we might need to export it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. In this case, the variable :artistID
will be taken from the path, but for other routes, we will need to either add the variables here or set the defaults within the GraphQL query.
I'm not sure if I can automate this work. So far, I have manually tested whether the prefetching worked and added the variables in case it hasn't... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining.
this past week with infinite-discovery
I tried prefetchQuery
and it failed because it's missing the query variables and only worked when I added them.
Let's move with this then and keep an eye on Sentry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should go the the route approach as that's our centralized hub which contains all screen dependencies and avoid adding details to our queries that can be handled on the JS side. Over in force this is how we do it:
- prepareVariables:
- And then in the RouterLink's
usePrefetchRoute
hook, we look it up:
So as things grow, and if we ever need to add anything more, the routes file / route item is the only place you need to go, and then just call findRoutesByPath
and pass it the route path in question. Has worked well over there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This PR adds missing screen queries to routes.tsx. The queries will be used for prefetching.
🤖 Generated with Claude Code
PR Checklist
To the reviewers 👀
Changelog updates
Changelog updates
Cross-platform user-facing changes
iOS user-facing changes
Android user-facing changes
Dev changes
routes.tsx
for prefetching - oleNeed help with something? Have a look at our docs, or get in touch with us.