-
Notifications
You must be signed in to change notification settings - Fork 1
/
codegen.yml
175 lines (173 loc) · 5.6 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
overwrite: true
schema:
- 'http://localhost:8080/v1/graphql':
headers:
'x-hasura-admin-secret': 'password'
'x-hasura-default-role': 'admin'
'x-hasura-role': 'admin'
generates:
# shared
libs/gql/shared/types/src/generated/index.ts:
plugins:
- 'typescript':
constEnums: true
# admin
libs/gql/admin/api/src/generated/schema.json:
plugins:
- 'introspection'
libs/gql/admin/api/src/generated/schema.graphql:
plugins:
- 'schema-ast'
libs/gql/admin/types/src/generated/index.ts:
documents: './libs/gql/admin/api/src/queries/**/*.{graphql,gql}'
preset: import-types
presetConfig:
typesPath: '@gql/shared/types'
importTypesNamespace: 'Types'
plugins:
- 'typescript-operations':
preResolveTypes: true
libs/gql/admin/api/src/generated/index.ts:
preset: import-types
presetConfig:
typesPath: '@gql/admin/types'
importTypesNamespace: 'Types'
documents: './libs/gql/admin/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-generic-sdk':
noExport: true
documentMode: 'string'
- 'add':
content: 'import { fetchData } from "@next/hasura/api";'
placement: 'prepend'
- 'add':
content: 'export const adminSdk = getSdk(fetchData({admin:true}));'
placement: 'append'
# user
libs/gql/user/api/src/generated/schema.json:
plugins:
- 'introspection'
schema:
- &userSchema
${NEXT_PUBLIC_HASURA_URL:http://localhost:8080/v1/graphql}:
headers:
'x-hasura-admin-secret': ${HASURA_GRAPHQL_ADMIN_SECRET:password}
'x-hasura-default-role': 'user'
'x-hasura-role': 'user'
libs/gql/user/api/src/generated/schema.graphql:
plugins:
- 'schema-ast'
schema:
- *userSchema
libs/gql/user/types/src/generated/index.ts:
preset: import-types
presetConfig:
typesPath: '@gql/shared/types'
importTypesNamespace: 'Types'
schema:
- *userSchema
documents: './libs/gql/user/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-operations':
preResolveTypes: true
libs/gql/user/react-query/src/generated/index.tsx:
preset: import-types
presetConfig:
typesPath: '@gql/user/types'
importTypesNamespace: 'Types'
schema:
- *userSchema
documents: './libs/gql/user/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-react-query':
fetcher:
func: '@next/hasura/react-query#fetchDataReactQuery'
isReactHook: false
errorType: Error
typesPrefix: 'Types.'
libs/gql/user/api/src/generated/index.ts:
preset: import-types
presetConfig:
typesPath: '@gql/user/types'
importTypesNamespace: 'Types'
documents: './libs/gql/user/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-generic-sdk':
noExport: true
documentMode: 'string'
- 'add':
content: 'import { fetchData } from "@next/hasura/api";'
placement: 'prepend'
- 'add':
content: 'export const userSdk = getSdk(fetchData());'
placement: 'append'
# anonymous
libs/gql/anonymous/api/src/generated/schema.json:
plugins:
- 'introspection'
schema:
- &anonymousSchema
${NEXT_PUBLIC_HASURA_URL:http://localhost:8080/v1/graphql}:
headers:
'x-hasura-admin-secret': ${HASURA_GRAPHQL_ADMIN_SECRET:password}
'x-hasura-default-role': 'anonymous'
'x-hasura-role': 'anonymous'
libs/gql/anonymous/api/src/generated/schema.graphql:
plugins:
- 'schema-ast'
schema:
- *anonymousSchema
libs/gql/anonymous/types/src/generated/index.ts:
preset: import-types
presetConfig:
typesPath: '@gql/shared/types'
importTypesNamespace: 'Types'
schema:
- *anonymousSchema
documents: './libs/gql/anonymous/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-operations':
preResolveTypes: true
libs/gql/anonymous/api/src/generated/index.ts:
preset: import-types
presetConfig:
typesPath: '@gql/anonymous/types'
importTypesNamespace: 'Types'
documents: './libs/gql/anonymous/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-generic-sdk':
noExport: true
documentMode: 'string'
- 'add':
content: 'import { fetchData } from "@next/hasura/api";'
placement: 'prepend'
- 'add':
content: 'export const anonymousSdk = getSdk(fetchData());'
placement: 'append'
libs/gql/anonymous/react-query/src/generated/index.tsx:
preset: import-types
presetConfig:
typesPath: '@gql/anonymous/types'
importTypesNamespace: 'Types'
schema:
- *anonymousSchema
documents: './libs/gql/anonymous/api/src/queries/**/*.{graphql,gql}'
plugins:
- 'typescript-react-query':
fetcher:
func: '@next/hasura/react-query#fetchDataReactQuery'
isReactHook: false
errorType: Error
typesPrefix: 'Types.'
# ## 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/allow_list.yaml:
# documents: './libs/gql/*/api/src/queries/**/*.{graphql,gql}'
# plugins:
# - 'hasura-allow-list':
# globalFragments: false
# hooks:
# afterOneFileWrite:
# - make restart-hasura