-
Notifications
You must be signed in to change notification settings - Fork 6
/
codegen.yml
87 lines (85 loc) · 2.75 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
overwrite: true
schema:
- 'http://localhost:8080/v1/graphql':
headers:
'x-hasura-admin-secret': 'password'
'x-hasura-default-role': 'admin'
'x-hasura-role': 'admin'
generates:
# admin
libs/client/gql/admin/src/generated/schema.json:
plugins:
- 'introspection'
libs/client/gql/admin/src/generated/schema.graphql:
plugins:
- 'schema-ast'
libs/client/gql/admin/src/generated/index.ts:
documents: './libs/client/gql/admin/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript':
constEnums: true
- 'typescript-operations':
preResolveTypes: true
- 'typescript-generic-sdk':
noExport: true
documentMode: 'string'
- 'add':
content: 'import { fetchData } from "@client/hasura/fetcher";'
placement: 'prepend'
- 'add':
content: 'export const adminSdk = getSdk(fetchData({admin:true}));'
placement: 'append'
# user
libs/client/gql/user/src/generated/schema.json:
plugins:
- 'introspection'
schema:
- &userSchema
${NEXT_PUBLIC_HASURA_URL:http://localhost:8080/v1/graphql}:
headers:
'x-hasura-admin-secret': ${HASURA_ADMIN_SECRET:password}
'x-hasura-default-role': 'user'
'x-hasura-role': 'user'
libs/client/gql/user/src/generated/schema.graphql:
plugins:
- 'schema-ast'
schema:
- *userSchema
libs/client/gql/user/src/generated/index.ts:
schema:
- *userSchema
documents: './libs/client/gql/user/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript':
constEnums: true
- 'typescript-operations':
preResolveTypes: true
- 'typescript-react-query':
fetcher:
func: '@client/hasura/fetcher#fetchDataReactQuery'
isReactHook: false
errorType: Error
# test user
libs/test-utils/gql/src/generated/test-user.ts:
schema:
- *userSchema
documents: './libs/client/gql/user/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript':
constEnums: true
- 'typescript-operations':
preResolveTypes: true
- 'typescript-generic-sdk':
noExport: true
documentMode: 'string'
# ## hasura
# # doesn't support yet separated fragments so it fail
# # TODO: follow up on this issue https://github.com/dotansimha/graphql-code-generator/issues/7700
# # ref: https://www.graphql-code-generator.com/plugins/other/hasura-allow-list
# hasura/app/metadata/query_collections.yaml:
# documents: './libs/client/gql/*/src/queries/**/*.{graphql,gql}'
# plugins:
# - 'hasura-allow-list'
# hooks:
# afterOneFileWrite:
# - make restart-hasura