-
Notifications
You must be signed in to change notification settings - Fork 2.7k
add clientSetup codemod
#12851
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
add clientSetup codemod
#12851
Conversation
🦋 Changeset detectedLatest commit: 0b00e09 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 📦
|
commit: |
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 32 new, 64 changed, 7 removedBuild ID: 65226bf5d5f9206282bf39b3 URL: https://www.apollographql.com/docs/deploy-preview/65226bf5d5f9206282bf39b3 |
apolloClientInitialization codemodclientSetup codemod
| } | ||
| const enabledStepNames = | ||
| Array.isArray(options.apolloClientInitialization) ? | ||
| options.apolloClientInitialization |
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 option is only meant for our tests to enable individual codemods, not for end users, that would get too granular.
| /* | ||
| Start: Inserted by Apollo Client 3->4 migration codemod. | ||
| Copy the contents of this block into a \`.d.ts\` file in your project | ||
| to enable data masking types. | ||
| */ | ||
| import "@apollo/client"; | ||
| import { GraphQLCodegenDataMasking } from "@apollo/client/masking"; | ||
| declare module "@apollo/client" { | ||
| export interface TypeOverrides extends GraphQLCodegenDataMasking.TypeOverrides {} | ||
| } | ||
| /* | ||
| End: Inserted by Apollo Client 3->4 migration codemod. | ||
| */ |
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 is inserted at the end of the file if dataMasking: true is detected in the options and it is a .ts/.tsx file.
The dataMasking: true gets an additional comment like
/*
Inserted by Apollo Client 3->4 migration codemod.
Keep this comment here if you intend to run the codemod again,
to avoid changes from being reapplied.
Delete this comment once you are done with the migration.
@apollo/client-codemod-migrate-3-to-4 applied
*/
dataMasking: true,and as long as at least
/* @apollo/client-codemod-migrate-3-to-4 applied */
dataMasking: true,stays in place, this will not be added to the file a second time when rerunning the codemod, even if the user deletes the block or moves it out into a separate file as instructed.
| /* | ||
| Start: Inserted by Apollo Client 3->4 migration codemod. | ||
| Copy the contents of this block into a \`.d.ts\` file in your project to enable correct response types in your custom links. | ||
| If you do not use the \`@defer\` directive in your application, you can safely remove this block. | ||
| */ | ||
| import "@apollo/client"; | ||
| import { Defer20220824Handler } from "@apollo/client/incremental"; | ||
| declare module "@apollo/client" { | ||
| export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {} | ||
| } | ||
| /* | ||
| End: Inserted by Apollo Client 3->4 migration codemod. | ||
| */" | ||
| `); |
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 is added at the end of the file if incrementalHandler was not present in the options previously and it is a .ts/.tsx file.
| /* | ||
| Inserted by Apollo Client 3->4 migration codemod. | ||
| If you are not using the \`@defer\` directive in your application, | ||
| you can safely remove this option. | ||
| */ | ||
| incrementalHandler: new Defer20220824Handler() |
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 will be added if no incrementalHandler option is found.
| /* | ||
| Inserted by Apollo Client 3->4 migration codemod. | ||
| If you are not using the \`@client\` directive in your application, | ||
| you can safely remove this option. | ||
| */ | ||
| localState: new LocalState({}) |
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.
If no resolvers option is found, a localState option will be added anyways, but then it has this preceding comment telling the user to delete it if they don't use @client directives.
That seemed preferrable to me over users missing out on getting it added by the codemod.
| uri: "/graphql", | ||
| credentials: "include", | ||
| headers: { | ||
| "x-custom-header": "value", | ||
| }, |
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.
moving into link
| cache: new InMemoryCache(), | ||
| ssrForceFetchDelay: 50, | ||
| ssrMode: true, | ||
| connectToDevTools: 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.
renamed to devTools.enabled
| defaultOptions: {}, | ||
| defaultContext: {}, | ||
| assumeImmutableResults: true, | ||
| resolvers: myResolvers, |
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.
moving into localState
| typeDefs: mySchema, | ||
| fragmentMatcher: () => 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.
these are removed
| name: "my-client", | ||
| version: "1.0.0", |
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.
moving into clientAwareness
jerelmiller
left a comment
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.
let's get it in
No description provided.