You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/development-testing/static-typing.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ export default config;
57
57
58
58
<Note>
59
59
60
-
There are multiple ways to [specify a schema](https://www.the-guild.dev/graphql/codegen/docs/config-reference/schema-field#root-level) in your `codegen.ts`, so pick whichever way works best for your project setup.
60
+
There are multiple ways to [specify a schema](https://www.the-guild.dev/graphql/codegen/docs/config-reference/schema-field#root-level) in your `codegen.ts`. Use the method that best fits your project's needs.
61
61
62
62
</Note>
63
63
@@ -83,7 +83,7 @@ $ npm run codegen
83
83
84
84
If you follow GraphQL Codegen's [quickstart guide](https://the-guild.dev/graphql/codegen/docs/getting-started/installation), it recommends generating your config file using the GraphQL Code Generator CLI. This wizard installs and configures the [`@graphql-codegen/client-preset`](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client).
85
85
86
-
We don't recommend using the client preset with Apollo Client apps because it generates additional runtime code that adds bundle size to your application and includes features that are incompatible with Apollo Client. We instead recommend using the [`typescript`](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript) and [`typescript-operations`](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations) plugins directly (at minimum) which focus on only generating types and doesn't include additional runtime code. Follow the steps in the previous section to use a setup that includes these plugins.
86
+
We do not recommend using the client preset with Apollo Client apps because it generates additional runtime code that adds bundle size to your application and includes features that are incompatible with Apollo Client. Instead, we recommend using the [`typescript`](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript) and [`typescript-operations`](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations) plugins directly (at minimum), which focus on only generating types and don't include additional runtime code. Follow the steps in the preceding section to use a setup that includes these plugins.
87
87
88
88
If you're already using the client preset, or you choose to use it instead of working directly with the plugins, we recommend the following minimal configuration for Apollo Client apps.
89
89
@@ -481,7 +481,7 @@ export function NewRocketForm() {
481
481
482
482
<Note>
483
483
484
-
Unlike `useQuery`, `useMutation` doesn't provide a `dataState` property. `data` isn't tracked the same way as `useQuery`since its value is not read from the cache. The value of `data` is a set result of the last execution of the mutation.
484
+
Unlike `useQuery`, `useMutation` doesn't provide a `dataState` property. `data` isn't tracked the same way as `useQuery`because its value is not read from the cache. The value of `data` is a set result of the last execution of the mutation.
485
485
486
486
</Note>
487
487
@@ -491,7 +491,7 @@ Unlike `useQuery`, `useMutation` doesn't provide a `dataState` property. `data`
491
491
492
492
This behavior affects how TypeScript checks required variables with `useMutation`. Required variables must be provided to either the hook or the mutate function. If a required variable is not provided to the hook, the mutate function must include it. Required variables provided to the hook make them optional in the mutate function.
493
493
494
-
The following uses the previous example but flattens out the variable declarations to demonstrate how required variables affects TypeScript validation.
494
+
The following uses the previous example but flattens the variable declarations to demonstrate how required variables affects TypeScript validation.
495
495
496
496
```tsx
497
497
const SAVE_ROCKET:TypedDocumentNode<
@@ -594,7 +594,7 @@ Variables are validated the same as `useQuery`. See [working with variables](#wo
594
594
595
595
## Defining context types
596
596
597
-
Apollo Client allows you to pass [custom context](../api/link/introduction#managing-context) through to the link chain. By default, context is typed as `Record<string, any>` to allow for any arbitrary value as context. However, this default has a couple downsides. You don't get proper type safety and you don't get autocomplete suggestions in your editor to understand what context options are available to you.
597
+
Apollo Client enables you to pass [custom context](../api/link/introduction#managing-context) through to the link chain. By default, context is typed as `Record<string, any>` to allow for any arbitrary value as context. However, this default has a few downsides. You don't get proper type safety and you don't get autocomplete suggestions in your editor to understand what context options are available to you.
598
598
599
599
You can define your own context types for better type safety in Apollo Client using TypeScript's [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html).
0 commit comments