Skip to content

Commit 4227a04

Browse files
committed
Add changeset
1 parent f5b255c commit 4227a04

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.changeset/fifty-books-return.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
```

0 commit comments

Comments
 (0)