From 759a280fec306ef238f35a146fce7f2e109488b2 Mon Sep 17 00:00:00 2001 From: pieh Date: Thu, 3 Nov 2022 13:37:21 +0100 Subject: [PATCH] feat(gatsby): handle graphql-import-node bundling --- packages/gatsby/package.json | 1 + .../gatsby/src/schema/graphql-engine/bundle-webpack.ts | 9 +++++++++ .../src/schema/graphql-engine/shims/no-op-module.js | 1 + yarn.lock | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 packages/gatsby/src/schema/graphql-engine/shims/no-op-module.js diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 31a79997fe400..06209d379f15e 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -110,6 +110,7 @@ "got": "^11.8.5", "graphql": "^16.6.0", "graphql-compose": "^9.0.9", + "graphql-tag": "^2.12.6", "hasha": "^5.2.2", "invariant": "^2.2.4", "is-relative": "^1.0.0", diff --git a/packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts b/packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts index 7cb69965847d4..1ffb9dbe56ac5 100644 --- a/packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts +++ b/packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts @@ -166,6 +166,12 @@ export async function createGraphqlEngineBundle( test: /\.txt/, type: `asset/resource`, }, + { + test: /\.(graphqls?|gqls?)$/, + use: { + loader: require.resolve(`graphql-tag/loader`), + }, + }, ], }, resolve: { @@ -180,6 +186,9 @@ export async function createGraphqlEngineBundle( lmdb: require.resolve(`lmdb`), "ts-node": require.resolve(`./shims/ts-node`), "gatsby-sharp$": require.resolve(`./shims/gatsby-sharp`), + "graphql-import-node$": require.resolve(`./shims/no-op-module`), + "graphql-import-node/register$": + require.resolve(`./shims/no-op-module`), }, }, plugins: [ diff --git a/packages/gatsby/src/schema/graphql-engine/shims/no-op-module.js b/packages/gatsby/src/schema/graphql-engine/shims/no-op-module.js new file mode 100644 index 0000000000000..e89c38a7a07c4 --- /dev/null +++ b/packages/gatsby/src/schema/graphql-engine/shims/no-op-module.js @@ -0,0 +1 @@ +// no-op diff --git a/yarn.lock b/yarn.lock index 64f99f5e964b5..f22a959ed7e6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11918,7 +11918,7 @@ graphql-request@^1.8.2: dependencies: cross-fetch "2.2.2" -graphql-tag@^2.11.0, graphql-tag@^2.12.3: +graphql-tag@^2.11.0, graphql-tag@^2.12.3, graphql-tag@^2.12.6: version "2.12.6" resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" integrity sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==