diff --git a/.changeset/lovely-adults-learn.md b/.changeset/lovely-adults-learn.md new file mode 100644 index 0000000000..7b513df243 --- /dev/null +++ b/.changeset/lovely-adults-learn.md @@ -0,0 +1,5 @@ +--- +"@bigcommerce/catalyst-core": patch +--- + +Introduces more consistent naming convention for files related to GraphQL, changes opinions around when it is appropriate to track GraphQL files in version control, fixes an issue where the `generate.cjs` script was swallowing helpful error messaging diff --git a/.gitignore b/.gitignore index 7fc5e57322..ae0b6b61f6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,6 @@ dist test-results/ playwright-report/ playwright/.cache/ -graphql-env.d.ts +bigcommerce.graphql +bigcommerce-graphql.d.ts .DS_Store diff --git a/core/.gitignore b/core/.gitignore index 8f1cb24252..d96c1399f9 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -40,7 +40,6 @@ next-env.d.ts # generated client/generated -schema.graphql # secrets .catalyst diff --git a/core/client/graphql.ts b/core/client/graphql.ts index a47f30abfd..c0d2346365 100644 --- a/core/client/graphql.ts +++ b/core/client/graphql.ts @@ -1,6 +1,6 @@ import { initGraphQLTada } from 'gql.tada'; -import type { introspection } from '~/graphql-env'; +import type { introspection } from '~/bigcommerce-graphql'; export const graphql = initGraphQLTada<{ introspection: introspection; diff --git a/core/scripts/generate.cjs b/core/scripts/generate.cjs index c60d815d59..84c8be1a9e 100644 --- a/core/scripts/generate.cjs +++ b/core/scripts/generate.cjs @@ -44,18 +44,24 @@ const getEndpoint = () => { }; const generate = async () => { - await generateSchema({ - input: getEndpoint(), - headers: { Authorization: `Bearer ${getToken()}` }, - output: join(__dirname, '../schema.graphql'), - tsconfig: undefined, - }); - - await generateOutput({ - disablePreprocessing: false, - output: join(__dirname, '../graphql-env.d.ts'), - tsconfig: undefined, - }); + try { + await generateSchema({ + input: getEndpoint(), + headers: { Authorization: `Bearer ${getToken()}` }, + output: join(__dirname, '../bigcommerce.graphql'), + tsconfig: undefined, + }); + + await generateOutput({ + disablePreprocessing: false, + output: undefined, + tsconfig: undefined, + }); + } catch (error) { + // eslint-disable-next-line no-console + console.error(error); + process.exit(1); + } }; generate(); diff --git a/core/tsconfig.json b/core/tsconfig.json index 09298c4de8..f5fb73a072 100644 --- a/core/tsconfig.json +++ b/core/tsconfig.json @@ -25,10 +25,15 @@ }, { "name": "@0no-co/graphqlsp", - "schema": "./schema.graphql", - "tadaOutputLocation": "./graphql-env.d.ts", "trackFieldUsage": false, - "shouldCheckForColocatedFragments": false + "shouldCheckForColocatedFragments": false, + "schemas": [ + { + "name": "bigcommerce", + "schema": "./bigcommerce.graphql", + "tadaOutputLocation": "./bigcommerce-graphql.d.ts" + } + ] } ], "baseUrl": ".",