-
Notifications
You must be signed in to change notification settings - Fork 583
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
feat: support metaphysics CDN and support cacheable #10842
Conversation
If so - wouldn't a dev notice in development that their query doesn't work? As in, they have a cacheable query. Then, they add a fragment that depends on access token (like something scoped under |
That's actually a good point @mzikherman - I can add some dev tooling to make sure that the error thrown shows a hint about |
0ba89d2
to
b7af2c9
Compare
} | ||
body = { query: require("../../../../../data/complete.queryMap.json")[queryID], variables } | ||
req.fetchOpts.body = JSON.stringify(body) | ||
return await next(req) |
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.
are we no longer using the persisted queries?, oh just saw your comment, I think it works when the query map in eigen is in line with MP? I could be wrong but think it works some time. I am not sure about how beneficial it actually is though, it does annoy me when trying to debug but could be a consequential change we should probably test.
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 am 100% in favor of removing this for the time being 👍 I feel like our concern for low powered devices is unwarranted given our demographic, and in any case, is trivial.
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.
This also vastly improves the developer experience, sentry experience, and so on and so forth. Its worth it.
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 am not opposed to it but I don't want us to just assume it will have no effect, the app is chatty and the bandwidth might add up, I think at least we should try to understand what the impact might be and monitor.
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.
Good point on Eigen being chatty @brainbicycle - Let me see if I can keep this then we can remove it in a separate PR. Here I deleted it because:
- I wanted to reproduce the experience on a production device as close as possible
- I wanted some to evaluate the improvement in latency
- I am not sure what will be the synergy like between the CDN and MP using the persisted queries 🤷 but I guess it will work out of the box 👀
9d7b202
to
388a95d
Compare
Interesting results with the CDN
Note: these are values from staging, I assume in production the impact will be greater! |
} | ||
|
||
// Helper method that returns the current URL | ||
export const getCurrentURL = () => { |
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 am glad I managed to use this helper that I spent hours to write at the beginning of the year
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.
Not necessarily for this PR, but it would be great to separate this stuff out. In force, etc, we have a
src/system/router
folder, and then inside that we should store utils related to the router
src/system/router/utils
Then all of the implementation details for our router can go in there, and our routes file can remain clear and behavioral.
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.
good idea - that should be fast to do. I will do it
@@ -13,7 +13,11 @@ import { useTracking } from "react-tracking" | |||
import { ArticlesList, ArticlesPlaceholder } from "./ArticlesList" | |||
|
|||
export const Articles: React.FC = () => { | |||
const queryData = useLazyLoadQuery<ArticlesQuery>(ArticlesScreenQuery, articlesQueryVariables) | |||
const queryData = useLazyLoadQuery<ArticlesQuery>(ArticlesScreenQuery, articlesQueryVariables, { |
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.
What we've done in Folio is define a useSystemQueryLoader
that encompasses this kind of default behavior, and then leaned on that: https://github.com/artsy/energy/blob/main/src/system/relay/useSystemQueryLoader.tsx.
As we're changing global behavior, we should hide as much implementation detail stuff as possible behind an artsy-specific API, and then evangelize that 👍
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 your feedback. Sorry for not answering this earlier. I think your comment here makes total sense. I was wondering why you went that direction in Force and in Folio but I think that's more future proof especially in cases like this where we want to update the behaviour in multiple screens.
This actually reminded me of this talk that I watched recently where the speaker is raising a good point about using your own hooks around state library / in our case this applies to relay hooks perfectly https://youtu.be/KI9xTG6wpeY?si=DR8Szsu3cr6EGnQm&t=379
? unsafe__getEnvironment().metaphysicsCDNURL | ||
: unsafe__getEnvironment().metaphysicsURL | ||
|
||
return metaphysicsURL |
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.
👍
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.
Code looks good @MounirDhahri ! thanks for diving into this. One suggestion about using a useSystemQueryLoader
hook and then updating various sections using that. From there we can continue building out a more specific API for relay operations in the app, from there.
cfb9b86
to
b1db98b
Compare
Description
This PR makes the following changes:
@cacheable
directiveBoth changes are hidden behind a feature flag
Open questions:
Me
) and the request will fail and there is nothing we can do to solve it from the CDN level. A retry strategy here seems like a requirement to me here 🤷useLazyLoadQuery
setsforce
totrue
always by default. Should we mimic that for network queries like in Force?PR Checklist
To the reviewers 👀
Changelog updates
Changelog updates
Cross-platform user-facing changes
iOS user-facing changes
Android user-facing changes
Dev changes
Need help with something? Have a look at our docs, or get in touch with us.