-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use printed query for deduplication, cache print calls #10968
Conversation
🦋 Changeset detectedLatest commit: 86bab47 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
src/utilities/graphql/print.ts
Outdated
import { canUseWeakMap } from "../common/canUse" | ||
|
||
const printCache = canUseWeakMap ? new WeakMap() : undefined; | ||
export const print: typeof print_orig = (ast) => { |
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 was thinking of using optimism
here, but optimism
doesn't use a WeakMap
internally, so printed "temporary" queries might hang around much longer that way.
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.
By chance, do you have an issue or reference on what prompted this change? I'd love to understand what this is fixing/improving.
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.
Would you mind adding this file to .prettierignore
and formatting this? Thanks!
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.
Will do so tomorrow :)
src/utilities/graphql/print.ts
Outdated
@@ -0,0 +1,14 @@ | |||
import { print as print_orig } from "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.
Would we avoid mixing casing and use origPrint
or printOrig
as the variable name here?
@jerelmiller it would save us from having to add something like apollographql/apollo-client-nextjs@305f0b7 to the There, we get the query streamed in from the server in a JSON-stringified DocumentNode and parse that. We want to simulate that query being active in Easiest way to support this on the client side would be to have the Apart from being a change for the nextjs bundle, this will also benefit users who declare their query twice with equal contents (as those before had no query deduplication), and will cache |
Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
@jerelmiller I applied your suggestions |
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.
🎉 🔥 👍 💯
Checklist:
This change should probably not need any new tests.