Skip to content

Commit 15d5007

Browse files
feat(cli): drop peerDep on "typescript" by using cosmiconfig-typescript-swc-loader (#8415)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a3a7a8a commit 15d5007

File tree

15 files changed

+517
-567
lines changed

15 files changed

+517
-567
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@graphql-codegen/cli": patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`cosmiconfig-typescript-swc-loader@0.0.2` ↗︎](https://www.npmjs.com/package/cosmiconfig-typescript-swc-loader/v/0.0.2) (to `dependencies`)
6+
- Removed dependency [`cosmiconfig-typescript-loader@4.0.0` ↗︎](https://www.npmjs.com/package/cosmiconfig-typescript-loader/v/4.0.0) (from `dependencies`)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
feat(cli): drop peerDep on "typescript" by using `cosmiconfig-typescript-swc-loader`

dev-test/codegen.ts

Lines changed: 359 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,359 @@
1+
import { CodegenConfig } from '@graphql-codegen/cli';
2+
3+
const config: CodegenConfig = {
4+
hooks: { afterAllFileWrite: ['prettier --write'] },
5+
emitLegacyCommonJSImports: false,
6+
generates: {
7+
'./dev-test/test-schema/resolvers-types.ts': {
8+
schema: './dev-test/test-schema/schema-text.js',
9+
plugins: ['typescript', 'typescript-resolvers'],
10+
},
11+
'./dev-test/test-schema/flow-types.flow.js': {
12+
schema: './dev-test/test-schema/schema.json',
13+
plugins: ['flow', 'flow-resolvers'],
14+
},
15+
'./dev-test/test-schema/resolvers-root.ts': {
16+
schema: './dev-test/test-schema/schema-with-root.graphql',
17+
plugins: ['typescript', 'typescript-resolvers'],
18+
},
19+
'./dev-test/test-schema/resolvers-federation.ts': {
20+
schema: './dev-test/test-schema/schema-federation.graphql',
21+
config: { federation: true },
22+
plugins: ['typescript', 'typescript-resolvers'],
23+
},
24+
'./dev-test/test-schema/resolvers-stitching.ts': {
25+
schema: './dev-test/test-schema/schema-text.js',
26+
plugins: ['typescript', { 'typescript-resolvers': { noSchemaStitching: false } }],
27+
},
28+
'./dev-test/test-schema/typings.ts': {
29+
schema: './dev-test/test-schema/schema.json',
30+
plugins: ['typescript', 'typescript-resolvers'],
31+
},
32+
'./dev-test/test-schema/typings.avoidOptionals.ts': {
33+
schema: './dev-test/test-schema/schema.json',
34+
config: { avoidOptionals: true },
35+
plugins: ['typescript'],
36+
},
37+
'./dev-test/test-schema/typings.wrapped.ts': {
38+
schema: './dev-test/test-schema/schema.json',
39+
plugins: [
40+
{ add: { content: 'declare namespace GraphQL {' } },
41+
{ add: { placement: 'append', content: '}' } },
42+
'typescript',
43+
'typescript-operations',
44+
],
45+
},
46+
'./dev-test/test-schema/env.types.ts': { schema: '${SCHEMA_PATH}', plugins: ['typescript'] },
47+
'./dev-test/test-schema/typings.immutableTypes.ts': {
48+
schema: './dev-test/test-schema/schema.json',
49+
config: { imutableTypes: true },
50+
plugins: ['typescript'],
51+
},
52+
'./dev-test/test-schema/typings.enum.ts': {
53+
schema: './dev-test/test-schema/schema-object.js',
54+
plugins: ['typescript'],
55+
},
56+
'./dev-test/githunt/graphql-declared-modules.d.ts': {
57+
schema: './dev-test/githunt/schema.json',
58+
documents: ['./dev-test/githunt/**/*.graphql'],
59+
plugins: ['typescript-graphql-files-modules'],
60+
},
61+
'./dev-test/githunt/typed-document-nodes.ts': {
62+
schema: './dev-test/githunt/schema.json',
63+
documents: './dev-test/githunt/**/*.graphql',
64+
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
65+
},
66+
'./dev-test/githunt/flow.flow.js': {
67+
schema: './dev-test/githunt/schema.json',
68+
documents: './dev-test/githunt/**/*.graphql',
69+
plugins: ['flow', 'flow-operations'],
70+
},
71+
'./dev-test/githunt/types.ts': {
72+
schema: './dev-test/githunt/schema.json',
73+
documents: './dev-test/githunt/**/*.graphql',
74+
plugins: ['typescript', 'typescript-operations'],
75+
},
76+
'./dev-test/githunt/types.preResolveTypes.ts': {
77+
schema: './dev-test/githunt/schema.json',
78+
documents: './dev-test/githunt/**/*.graphql',
79+
config: { preResolveTypes: true },
80+
plugins: ['typescript', 'typescript-operations'],
81+
},
82+
'./dev-test/githunt/types.onlyEnums.ts': {
83+
schema: './dev-test/githunt/schema.json',
84+
documents: './dev-test/githunt/**/*.graphql',
85+
config: { onlyEnums: true },
86+
plugins: ['typescript'],
87+
},
88+
'./dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts': {
89+
schema: './dev-test/githunt/schema.json',
90+
documents: './dev-test/githunt/**/*.graphql',
91+
config: { preResolveTypes: true, onlyOperationTypes: true },
92+
plugins: ['typescript', 'typescript-operations'],
93+
},
94+
'./dev-test/githunt/types.flatten.preResolveTypes.ts': {
95+
schema: './dev-test/githunt/schema.json',
96+
documents: './dev-test/githunt/**/*.graphql',
97+
config: { preResolveTypes: true, flattenGeneratedTypes: true },
98+
plugins: ['typescript', 'typescript-operations'],
99+
},
100+
'./dev-test/githunt/types.enumsAsTypes.ts': {
101+
schema: './dev-test/githunt/schema.json',
102+
documents: './dev-test/githunt/**/*.graphql',
103+
config: { enumsAsTypes: true },
104+
plugins: ['typescript', 'typescript-operations'],
105+
},
106+
'./dev-test/githunt/types.d.ts': {
107+
schema: './dev-test/githunt/schema.json',
108+
documents: './dev-test/githunt/**/*.graphql',
109+
config: { enumsAsTypes: true },
110+
plugins: ['typescript', 'typescript-operations'],
111+
},
112+
'./dev-test/githunt/types.avoidOptionals.ts': {
113+
schema: './dev-test/githunt/schema.json',
114+
documents: './dev-test/githunt/**/*.graphql',
115+
config: { avoidOptionals: true },
116+
plugins: ['typescript', 'typescript-operations'],
117+
},
118+
'./dev-test/githunt/types.immutableTypes.ts': {
119+
schema: './dev-test/githunt/schema.json',
120+
documents: './dev-test/githunt/**/*.graphql',
121+
config: { immutableTypes: true },
122+
plugins: ['typescript', 'typescript-operations'],
123+
},
124+
'./dev-test/githunt/types.reactApollo.tsx': {
125+
schema: './dev-test/githunt/schema.json',
126+
documents: './dev-test/githunt/**/*.graphql',
127+
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
128+
},
129+
'./dev-test/githunt/types.reactApollo.v2.tsx': {
130+
schema: './dev-test/githunt/schema.json',
131+
documents: './dev-test/githunt/**/*.graphql',
132+
config: { reactApolloVersion: 2 },
133+
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
134+
},
135+
'./dev-test/githunt/types.reactApollo.customSuffix.tsx': {
136+
schema: './dev-test/githunt/schema.json',
137+
documents: './dev-test/githunt/**/*.graphql',
138+
config: { operationResultSuffix: 'MyOperation' },
139+
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
140+
},
141+
'./dev-test/githunt/types.reactApollo.preResolveTypes.tsx': {
142+
schema: './dev-test/githunt/schema.json',
143+
documents: './dev-test/githunt/**/*.graphql',
144+
config: { preResolveTypes: true },
145+
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
146+
},
147+
'./dev-test/githunt/types.reactApollo.hooks.tsx': {
148+
schema: './dev-test/githunt/schema.json',
149+
documents: './dev-test/githunt/**/*.graphql',
150+
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
151+
},
152+
'./dev-test/githunt/types.react-query.ts': {
153+
schema: './dev-test/githunt/schema.json',
154+
documents: './dev-test/githunt/**/*.graphql',
155+
plugins: ['typescript', 'typescript-operations', 'typescript-react-query'],
156+
config: { addInfiniteQuery: true },
157+
},
158+
'./dev-test/githunt/types.rtk-query.ts': {
159+
schema: './dev-test/githunt/schema.json',
160+
documents: './dev-test/githunt/**/*.graphql',
161+
plugins: [
162+
{ add: { content: 'module.hot?.accept();' } },
163+
'typescript',
164+
'typescript-operations',
165+
{
166+
'typescript-rtk-query': {
167+
importBaseApiFrom: '../../packages/plugins/typescript/rtk-query/tests/baseApi',
168+
exportHooks: true,
169+
overrideExisting: 'module.hot?.status() === "apply"',
170+
},
171+
},
172+
],
173+
},
174+
'./dev-test/githunt/types.apolloAngular.ts': {
175+
schema: './dev-test/githunt/schema.json',
176+
documents: './dev-test/githunt/**/*.graphql',
177+
plugins: ['typescript', 'typescript-operations', 'typescript-apollo-angular'],
178+
},
179+
'./dev-test/githunt/types.apolloAngular.sdk.ts': {
180+
schema: './dev-test/githunt/schema.json',
181+
documents: './dev-test/githunt/**/*.graphql',
182+
config: { sdkClass: true },
183+
plugins: ['typescript', 'typescript-operations', 'typescript-apollo-angular'],
184+
},
185+
'./dev-test/githunt/types.stencilApollo.tsx': {
186+
schema: './dev-test/githunt/schema.json',
187+
documents: './dev-test/githunt/**/*.graphql',
188+
plugins: ['typescript', 'typescript-operations', 'typescript-stencil-apollo'],
189+
},
190+
'./dev-test/githunt/types.urql.tsx': {
191+
schema: './dev-test/githunt/schema.json',
192+
documents: './dev-test/githunt/**/*.graphql',
193+
plugins: [
194+
'typescript',
195+
'typescript-operations',
196+
'typescript-urql',
197+
'urql-introspection',
198+
'typescript-urql-graphcache',
199+
],
200+
},
201+
'./dev-test/githunt': {
202+
schema: './dev-test/githunt/schema.json',
203+
documents: [
204+
'./dev-test/githunt/**/*.graphql',
205+
'./dev-test/githunt-invalid/**/*.graphql',
206+
'!./dev-test/githunt-invalid/**/*.graphql',
207+
],
208+
preset: 'near-operation-file',
209+
presetConfig: { extension: '.stencil-component.tsx', folder: '__generated__', baseTypesPath: 'types.d.ts' },
210+
plugins: ['typescript-operations', 'typescript-stencil-apollo'],
211+
config: { componentType: 'class', globalNamespace: true },
212+
},
213+
'./dev-test/githunt/types.vueApollo.ts': {
214+
schema: './dev-test/githunt/schema.json',
215+
documents: './dev-test/githunt/**/*.graphql',
216+
plugins: ['typescript', 'typescript-operations', 'typescript-vue-apollo'],
217+
},
218+
'./dev-test/githunt/types.vueApolloSmartOps.ts': {
219+
schema: './dev-test/githunt/schema.json',
220+
documents: './dev-test/githunt/**/*.graphql',
221+
plugins: ['typescript', 'typescript-operations', 'typescript-vue-apollo-smart-ops'],
222+
},
223+
'./dev-test/githunt/jit-sdk.ts': {
224+
schema: './dev-test/githunt/schema.json',
225+
documents: './dev-test/githunt/**/*.graphql',
226+
plugins: ['typescript', 'typescript-operations', 'typescript-jit-sdk'],
227+
},
228+
'./dev-test/star-wars/types.ts': {
229+
schema: './dev-test/star-wars/schema.json',
230+
documents: './dev-test/star-wars/**/*.graphql',
231+
plugins: ['typescript', 'typescript-operations'],
232+
},
233+
'./dev-test/star-wars/types.preResolveTypes.ts': {
234+
schema: './dev-test/star-wars/schema.json',
235+
documents: './dev-test/star-wars/**/*.graphql',
236+
config: { preResolveTypes: true },
237+
plugins: ['typescript', 'typescript-operations'],
238+
},
239+
'./dev-test/star-wars/types.OnlyEnums.ts': {
240+
schema: './dev-test/star-wars/schema.json',
241+
documents: './dev-test/star-wars/**/*.graphql',
242+
config: { onlyEnums: true },
243+
plugins: ['typescript'],
244+
},
245+
'./dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts': {
246+
schema: './dev-test/star-wars/schema.json',
247+
documents: './dev-test/star-wars/**/*.graphql',
248+
config: { preResolveTypes: true, onlyOperationTypes: true },
249+
plugins: ['typescript', 'typescript-operations'],
250+
},
251+
'./dev-test/test-schema/types.preResolveTypes.ts': {
252+
schema: './dev-test/test-schema/schema.graphql',
253+
documents: ['query test { testArr1 testArr2 testArr3 }'],
254+
config: { preResolveTypes: true },
255+
plugins: ['typescript', 'typescript-operations'],
256+
},
257+
'./dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts': {
258+
schema: './dev-test/test-schema/schema.graphql',
259+
documents: ['query test { testArr1 testArr2 testArr3 }'],
260+
config: { preResolveTypes: true, onlyOperationTypes: true },
261+
plugins: ['typescript', 'typescript-operations'],
262+
},
263+
'./dev-test/star-wars/types.d.ts': {
264+
schema: './dev-test/star-wars/schema.json',
265+
config: { enumsAsTypes: true },
266+
plugins: ['typescript', 'typescript-operations'],
267+
},
268+
'./dev-test/star-wars': {
269+
schema: './dev-test/star-wars/schema.json',
270+
documents: './dev-test/star-wars/**/*.graphql',
271+
preset: 'near-operation-file',
272+
presetConfig: { extension: '.tsx', folder: '__generated__', baseTypesPath: 'types.d.ts' },
273+
plugins: ['typescript-operations', 'typescript-react-apollo'],
274+
},
275+
'./dev-test/modules/': {
276+
schema: './dev-test/modules/*/types/*.graphql',
277+
preset: 'graphql-modules',
278+
presetConfig: { baseTypesPath: 'types.ts', filename: 'generated.ts' },
279+
plugins: ['typescript', 'typescript-resolvers'],
280+
},
281+
'./dev-test/star-wars/types.globallyAvailable.d.ts': {
282+
schema: './dev-test/star-wars/schema.json',
283+
documents: './dev-test/star-wars/**/*.graphql',
284+
config: { enumsAsTypes: true, noExport: true },
285+
plugins: ['typescript', 'typescript-operations'],
286+
},
287+
'./dev-test/star-wars/types.avoidOptionals.ts': {
288+
schema: './dev-test/star-wars/schema.json',
289+
documents: './dev-test/star-wars/**/*.graphql',
290+
config: { avoidOptionals: true },
291+
plugins: ['typescript', 'typescript-operations'],
292+
},
293+
'./dev-test/star-wars/types.immutableTypes.ts': {
294+
schema: './dev-test/star-wars/schema.json',
295+
documents: './dev-test/star-wars/**/*.graphql',
296+
config: { immutableTypes: true },
297+
plugins: ['typescript', 'typescript-operations'],
298+
},
299+
'./dev-test/star-wars/types.skipSchema.ts': {
300+
schema: './dev-test/star-wars/schema.json',
301+
documents: './dev-test/star-wars/**/*.graphql',
302+
plugins: ['typescript', 'typescript-operations'],
303+
},
304+
'./dev-test/star-wars/types.refetchFn.tsx': {
305+
schema: './dev-test/star-wars/schema.json',
306+
documents: './dev-test/star-wars/**/*.graphql',
307+
plugins: ['typescript', 'typescript-react-apollo'],
308+
config: { withRefetchFn: true },
309+
},
310+
'./dev-test/test-message/types.tsx': {
311+
schema: './dev-test/test-message/schema.graphql',
312+
documents: './dev-test/test-message/documents.ts',
313+
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
314+
config: {
315+
documentMode: 'external',
316+
importDocumentNodeExternallyFrom: './documents.ts',
317+
reactApolloVersion: 3,
318+
gqlImport: 'graphql-tag',
319+
hooksImportFrom: '@apollo/react-hooks',
320+
withMutationFn: false,
321+
},
322+
},
323+
'./dev-test/gql-tag-operations/gql': {
324+
schema: './dev-test/gql-tag-operations/schema.graphql',
325+
documents: './dev-test/gql-tag-operations/src/**/*.ts',
326+
preset: 'gql-tag-operations-preset',
327+
plugins: [],
328+
},
329+
'./dev-test/gql-tag-operations/graphql': {
330+
schema: './dev-test/gql-tag-operations/schema.graphql',
331+
documents: './dev-test/gql-tag-operations/src/**/*.ts',
332+
preset: 'client',
333+
plugins: [],
334+
},
335+
'./dev-test/gql-tag-operations-urql/gql': {
336+
schema: './dev-test/gql-tag-operations-urql/schema.graphql',
337+
documents: './dev-test/gql-tag-operations-urql/src/**/*.ts',
338+
preset: 'gql-tag-operations-preset',
339+
presetConfig: { augmentedModuleName: '@urql/core' },
340+
plugins: [],
341+
},
342+
'./dev-test/gql-tag-operations-masking/gql': {
343+
schema: './dev-test/gql-tag-operations-masking/schema.graphql',
344+
documents: './dev-test/gql-tag-operations-masking/src/**/*.tsx',
345+
preset: 'gql-tag-operations-preset',
346+
presetConfig: { fragmentMasking: true },
347+
plugins: [],
348+
},
349+
'./dev-test/gql-tag-operations-masking-star-wars/gql': {
350+
schema: './dev-test/gql-tag-operations-masking-star-wars/schema.json',
351+
documents: './dev-test/gql-tag-operations-masking-star-wars/src/**/*.tsx',
352+
preset: 'gql-tag-operations-preset',
353+
presetConfig: { fragmentMasking: true },
354+
plugins: [],
355+
},
356+
},
357+
};
358+
359+
export default config;

0 commit comments

Comments
 (0)