Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MounirDhahri
Copy link
Member

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

Use case Screenshot
Dev added @cacheable to a query where force is set to true Simulator Screenshot - iPhone 16 Pro - 2024-09-26 at 09 49 25
Dev added @cacheable to a query where nocache is present in the URL Simulator Screenshot - iPhone 16 Pro - 2024-09-26 at 09 48 05
Dev added @cacheable to a query where a specialized argument is present Simulator Screenshot - iPhone 16 Pro - 2024-09-26 at 09 52 38

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

iOS user-facing changes

Android user-facing changes

Dev changes

  • Improve DX in @cacheable - mounir

Need help with something? Have a look at our docs, or get in touch with us.

})
}

return encodeURI(`${webURL}${path}`)
const queryParamsString = queryParams.map((params) =>
Copy link
Member Author

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) {
Copy link
Member Author

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

@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Sep 26, 2024

This PR contains the following changes:

  • Dev changes (Improve DX in @cacheable - mounir)

Generated by 🚫 dangerJS against 7c57f9a

araujobarret
araujobarret previously approved these changes Sep 26, 2024
Copy link
Contributor

@araujobarret araujobarret left a 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(
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

@araujobarret araujobarret Sep 26, 2024

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"]
Copy link
Contributor

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?

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants