| 4 | import type { IGraphQLConfig } from "graphql-config"; |
| 5 | |
| 6 | function getConfig() { |
| 7 | const config: IGraphQLConfig = { |
| 8 | projects: { |
| 9 | default: shopifyApiProject({ |
| 10 | apiType: ApiType.Admin, |
| 11 | apiVersion: LATEST_API_VERSION, |
| 12 | documents: ["./app/**/*.{js,ts,jsx,tsx}", "./app/.server/**/*.{js,ts,jsx,tsx}"], |
| 13 | outputDir: "./app/types", |
| 14 | }), |
| 15 | }, |
| 16 | }; |
| 17 | |
| 18 | let extensions: string[] = []; |
| 19 | try { |
| 20 | extensions = fs.readdirSync("./extensions"); |
| 21 | } catch { |
| 22 | // ignore if no extensions |
| 23 | } |
| 24 | |
| 25 | for (const entry of extensions) { |
| 26 | const extensionPath = `./extensions/${entry}`; |
| 27 | const schema = `${extensionPath}/schema.graphql`; |
| 28 | if (!fs.existsSync(schema)) { |
| 29 | continue; |
| 30 | } |
| 31 | config.projects[entry] = { |
| 32 | schema, |
| 33 | documents: [`${extensionPath}/**/*.graphql`], |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | return config; |
| 38 | } |
| 39 | |
| 40 | const config = getConfig(); |
| 41 | |