-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcodegen.yml
52 lines (52 loc) · 2.2 KB
/
codegen.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
overwrite: true
schema:
- 'api/**/*.schema.ts'
config:
# https://graphql-code-generator.com/docs/generated-config/typescript#maybevalue-string-default-value-t--null
maybeValue: T | null | undefined
generates:
# For API
api/generated/graphql.ts:
plugins:
- 'typescript'
- 'typescript-resolvers'
config:
# This is needed for apollo
# https://github.com/dotansimha/graphql-code-generator/blob/master/docs/plugins/typescript-resolvers.md#intergration-with-apollo-server
useIndexSignature: true
# Passing the GraphQLContext type automatically to the generated types
# https://github.com/dotansimha/graphql-code-generator/blob/master/docs/plugins/typescript-resolvers.md#custom-context-type
contextType: '@api/shared/shared.types#GQLContext'
# To map our TypeScript model interfaces to GraphQL types
# For example, if "Query.post" doesn't return the all fields of "Post" type,
# and they have field resolvers like "Post.viewerHasReacted", "Post.likesCount" etc,
# TypeScript complains about that the "Query.post" doesn't return the full model.
# (Especially if the model has non-null fields).
# To solve the differences between TypeScript models and the models which returned by the resolvers,
# we use mappers.
# https://github.com/dotansimha/graphql-code-generator/blob/master/docs/plugins/typescript-resolvers.md#mappers---overwrite-parents-and-resolved-values
# https://github.com/dotansimha/graphql-code-generator/issues/1219#issuecomment-549244957
mappers:
Post: '@api/shared/shared.types#PostMapper'
Category: '@api/shared/shared.types#CategoryMapper'
Comment: '@api/shared/shared.types#CommentMapper'
User: '@api/shared/shared.types#UserMapper'
# For client-side
src/generated/graphql.ts:
documents:
- 'src/**/*.{ts,tsx}'
- '!.next'
- '!node_modules'
plugins:
- 'typescript'
- 'typescript-operations'
- 'typescript-react-apollo'
config:
withHooks: true
withHOC: false
withComponent: false
# for @apollo/client 3
reactApolloVersion: 3
src/generated//graphql.schema.json:
plugins:
- 'introspection'