-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update scalar input/output related CHANGELOG with new recommended codegen config #9491
Changes from all commits
e3a0ac4
5b1c8f4
c468953
8cf9b33
458e63b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,8 +130,9 @@ export default config | |
**Usage with `@tanstack/react-query`** | ||
|
||
If you are using `@tanstack/react-query`, we recommend using it with `graphql-request@^5.0.0` to get the best developer experience. | ||
<br/> | ||
If you are willing to provide your own fetcher, you can directly jump to the ["Appendix I: React Query with a custom fetcher setup"](#appendix-i-react-query-with-a-custom-fetcher-setup) and continue the guide once React Query is properly setup. | ||
Comment on lines
-133
to
-134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why prettier didn't catch this in the previous PRs 🤔 |
||
|
||
If you are willing to provide your own fetcher, you can directly jump to the ["Appendix I: React Query with a custom fetcher | ||
setup"](#appendix-i-react-query-with-a-custom-fetcher-setup) and continue the guide once React Query is properly setup. | ||
|
||
</Callout> | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When this page is rendered, the I wonder if we should switch it, so the Usage example is first, then |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ You can find [a blog post we wrote about using and customizing this plugin here] | |
|
||
</Callout> | ||
|
||
Run `graphql-codegen` as usual, with this new plugin: | ||
Run `graphql-codegen` with `typescript-resolvers` plugin and the following config: | ||
|
||
```ts filename="codegen.ts" | ||
import type { CodegenConfig } from '@graphql-codegen/cli' | ||
|
@@ -42,7 +42,16 @@ const config: CodegenConfig = { | |
schema: 'schema.json', | ||
generates: { | ||
'./src/resolvers-types.ts': { | ||
plugins: ['typescript', 'typescript-resolvers'] | ||
plugins: ['typescript', 'typescript-resolvers'], | ||
config: { | ||
scalars: { | ||
// This option is required to match how GraphQL servers handle ID scalar | ||
ID: { | ||
input: 'string', | ||
output: 'string | number' | ||
} | ||
} | ||
} | ||
Comment on lines
+46
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added this section with the new config. |
||
} | ||
} | ||
} | ||
|
@@ -79,6 +88,7 @@ const config: CodegenConfig = { | |
'./resolvers-types.ts': { | ||
config: { | ||
useIndexSignature: true | ||
// ... other config options | ||
}, | ||
plugins: ['typescript', 'typescript-resolvers'] | ||
} | ||
|
@@ -108,6 +118,7 @@ const config: CodegenConfig = { | |
User: './models#UserModel', | ||
Profile: './models#UserProfile' | ||
} | ||
// ... other config options | ||
}, | ||
plugins: ['typescript', 'typescript-resolvers'] | ||
} | ||
|
@@ -150,6 +161,7 @@ const config: CodegenConfig = { | |
enumValues: { | ||
Color: './enums#ColorsCode' | ||
} | ||
// ... other config options | ||
}, | ||
plugins: ['typescript', 'typescript-resolvers'] | ||
} | ||
|
@@ -196,6 +208,7 @@ const config: CodegenConfig = { | |
BLUE: '#0000FF' | ||
} | ||
} | ||
// ... other config options | ||
}, | ||
plugins: ['typescript', 'typescript-resolvers'] | ||
} | ||
|
@@ -217,6 +230,7 @@ const config: CodegenConfig = { | |
mappers: { | ||
Color: './enums#ColorsCode' | ||
} | ||
// ... other config options | ||
}, | ||
plugins: ['typescript', 'typescript-resolvers'] | ||
} | ||
|
@@ -249,6 +263,7 @@ const config: CodegenConfig = { | |
...sharedMappers, | ||
String: 'StringType' | ||
} | ||
// ... other config options | ||
} | ||
}, | ||
'resolvers-types-2.ts': { | ||
|
@@ -258,6 +273,7 @@ const config: CodegenConfig = { | |
...sharedMappers, | ||
String: 'StringType' | ||
} | ||
// ... other config options | ||
} | ||
} | ||
} | ||
|
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've also update the GraphQL server guides with recommended scalars config