-
Notifications
You must be signed in to change notification settings - Fork 0
/
.graphqlrc.ts
40 lines (35 loc) · 997 Bytes
/
.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
import { ApiType, shopifyApiProject } from "@shopify/api-codegen-preset";
import { ApiVersion } from "@shopify/shopify-api";
import fs from "fs";
import type { IGraphQLConfig } from "graphql-config";
function getConfig() {
const config: IGraphQLConfig = {
projects: {
default: shopifyApiProject({
apiType: ApiType.Admin,
apiVersion: ApiVersion.Unstable,
documents: ["./app/**/*.{js,ts,jsx,tsx,graphql,gql}"],
outputDir: "./app/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)) {
continue;
}
config.projects[entry] = {
schema,
documents: [`${extensionPath}/**/*.graphql`],
};
}
return config;
}
module.exports = getConfig();