File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @apollo/client-graphql-codegen " : minor
3+ ---
4+
5+ Introduce a new GraphQL Codegen plugin to generate the type policy configuration needed to configure custom scalars for each field.
6+
7+ ``` ts
8+ // codegen.ts
9+ import type { ScalarTypePoliciesPluginConfig } from " @apollo/client-graphql-codegen/scalar-type-policies" ;
10+
11+ const config: CodegenConfig = {
12+ // ...
13+ generates: {
14+ " ./path/to/schema-type-policies.ts" : {
15+ plugins: [" @apollo/client-graphql-codegen/scalar-type-policies" ],
16+ config: {
17+ // ...
18+ } satisfies ScalarTypePoliciesPluginConfig ,
19+ },
20+ },
21+ };
22+ ```
23+
24+ This will generate a ` scalarTypePolicies ` object in the generated file that can be used to configure type policies.
25+
26+ ``` ts
27+ import { scalarTypePolicies } from " ./path/to/schema-type-policies" ;
28+
29+ const cache = new InMemoryCache ();
30+
31+ cache .policies .addTypePolicies (scalarTypePolicies );
32+ ```
You can’t perform that action at this time.
0 commit comments