-
Notifications
You must be signed in to change notification settings - Fork 573
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: better DX around for @cacheable #10847
Conversation
}) | ||
} | ||
|
||
return encodeURI(`${webURL}${path}`) | ||
const queryParamsString = queryParams.map((params) => |
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.
the query params where not present in the helper so I added them here
@@ -16,18 +17,34 @@ export const shouldSkipCDNCache = (req: GraphQLRequest) => { | |||
// - a known personalized argument is present in the query (for example `include_artworks_by_followed_artists`) | |||
// - nocache param is present in the url | |||
|
|||
if (req.cacheConfig?.force === true) { |
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 moved this down since it will be covered by the default case anyway
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.
Looks good, left small comments only
if (isRequestCacheable(req)) { | ||
if (req.cacheConfig?.force === true) { | ||
if (__DEV__) { | ||
console.warn( |
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.
can we use info here? These warnings in the simulators/emulators are pretty annoying
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 tried both actually but they both seems equally ugly 🥲 except that the warn shows the count better
Screen.Recording.2024-09-26.at.10.38.46.mov
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.
😢 then I'd vote only to console.log, these bubbles are bad for DX because they block the screen and all the time we have to close them
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 agree that console.warns can be annoying, but that's only if you can't dismiss them or don't know why they're occuring. Here, the action item should be clear, for example you need to remove @cacheable
. I do though think it's bad DX to declare your query as cacheable, expecting it to be cacheable, but it's not cacheable because something changed in the arguments and you aren't aware of 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.
yeah, after a 2nd thought I'm fine with it, it should really pester someone in this case, 👍 for the .warn then
@@ -19,11 +19,11 @@ export const hasNoCacheParamPresent = (url: string) => { | |||
return false | |||
} | |||
|
|||
export const SKIP_CACHE_ARGUMENTS = ["includeArtworksByFollowedArtists", "collectionID"] |
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.
isn't better to add some comments around it to give engineers direction and/or maybe add it to some docs about cache in Eigen?
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.
that's a valid point - we need something like this but for Eigen. I will draft something
Description
This PR makes a few adjustments to follow up on
@cacheable
PR. The goal here is to make it clear to developers when@cacheable
is not going to take effect@cacheable
to a query whereforce
is set totrue
@cacheable
to a query wherenocache
is present in the URL@cacheable
to a query where a specialized argument is presentPR Checklist
To the reviewers 👀
Changelog updates
Changelog updates
Cross-platform user-facing changes
iOS user-facing changes
Android user-facing changes
Dev changes
@cacheable
- mounirNeed help with something? Have a look at our docs, or get in touch with us.