forked from bkegley/luminate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.js
More file actions
85 lines (83 loc) · 2.68 KB
/
codegen.js
File metadata and controls
85 lines (83 loc) · 2.68 KB
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
const clientGenerates = {
'packages/admin/src/graphql/index.tsx': {
documents: 'packages/admin/src/graphql/**/*.graphql',
schema: 'http://localhost:3000/graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
config: {
withComponent: false,
withHOC: false,
withHooks: true,
nonOptionalTypename: true,
federation: true,
},
},
'packages/gatsby-theme-luminate/src/graphql/index.tsx': {
documents: 'packages/gatsby-theme-luminate/src/graphql/**/*.graphql',
schema: 'http://localhost:3000/graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
config: {
withComponent: false,
withHOC: false,
withHooks: true,
nonOptionalTypename: true,
federation: true,
},
},
}
const serverGenerates = {
'packages/graphql-utils/src/types.ts': {
plugins: ['typescript'],
},
'packages/server-auth/src/types.d.ts': {
schema: ['./packages/server-auth/src/schema/**/!(index.ts)*.ts'],
plugins: ['typescript', 'typescript-resolvers'],
config: {
contextType: './startServer#Context',
useIndexSignature: true,
federation: true,
mappers: {
Role: '@luminate/mongo#RoleDocument',
Scope: '@luminate/mongo#ScopeDocument',
User: '@luminate/mongo#UserDocument',
},
},
},
'packages/server-encyclopedia/src/types.d.ts': {
schema: ['./packages/server-encyclopedia/src/schema/**/!(index.ts)*.ts'],
plugins: ['typescript', 'typescript-resolvers'],
config: {
contextType: './startServer#Context',
useIndexSignature: true,
federation: true,
mappers: {
Coffee: '@luminate/mongo#CoffeeDocument',
Country: '@luminate/mongo#CountryDocument',
Farm: '@luminate/mongo#FarmDocument',
FarmZone: '@luminate/mongo#FarmZoneDocument',
Region: '@luminate/mongo#RegionDocument',
Variety: '@luminate/mongo#VarietyDocument',
},
},
},
'packages/server-sensory-eval/src/types.d.ts': {
schema: ['./packages/server-sensory-eval/src/schema/**/!(index.ts)*.ts'],
plugins: ['typescript', 'typescript-resolvers'],
config: {
contextType: './startServer#Context',
useIndexSignature: true,
federation: true,
mappers: {
Cupping: '@luminate/mongo#CuppingDocument',
CuppingCoffee: '@luminate/mongo#CoffeeCuppingDocument',
},
},
},
}
module.exports = {
schema: ['./packages/graphql-utils/src/schema/**/*.ts'],
generates: Object.assign(
{},
process.argv.find(arg => arg === '--client') ? clientGenerates : null,
process.argv.find(arg => arg === '--server') ? serverGenerates : null,
),
}