-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.graphqlrc.ts
51 lines (41 loc) · 1.23 KB
/
.graphqlrc.ts
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
import fs from 'node:fs'
import { ApiVersion } from '@shopify/shopify-api'
import { ApiType, shopifyApiProject } from '@shopify/api-codegen-preset'
import type { IGraphQLConfig } from 'graphql-config'
// No idea what any of this does, or how it works!
function getConfig() {
const config: IGraphQLConfig = {
projects: {
app: shopifyApiProject({
apiType: ApiType.Admin,
apiVersion: ApiVersion.April24,
documents: ['./app/pages/**/*.{ts,vue}', './app/components/**/*.{ts,vue}'],
outputDir: './app/types',
}),
default: shopifyApiProject({
apiType: ApiType.Admin,
apiVersion: ApiVersion.April24,
documents: ['./app/server/**/*.ts'],
outputDir: './app/server/types',
}),
},
}
let extensions: string[] = []
try {
extensions = fs.readdirSync('./extensions')
} catch {
// ignore if no extensions
}
for (const entry of extensions) {
const extensionPath = `./extensions/${entry}`
const schema = `${extensionPath}/schema.graphql`
if (fs.existsSync(schema)) {
config.projects[entry] = {
schema,
documents: [`${extensionPath}/**/*.graphql`],
}
}
}
return config
}
module.exports = getConfig()