From 1926b4e5a4044ce0e60bdea04430627520f0a1b8 Mon Sep 17 00:00:00 2001 From: GatsbyJS Bot Date: Thu, 3 Nov 2022 08:28:04 -0600 Subject: [PATCH] feat(gatsby): handle graphql-import-node bundling (#36951) (#36953) (cherry picked from commit d5c775afa6b5b5a61604a74f44ad25504f916c8f) Co-authored-by: Michal Piechowiak --- 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 fc5c488d3840b..65a7a2aa42322 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -110,6 +110,7 @@ "graphql": "^15.7.2", "graphql-compose": "^9.0.7", "graphql-playground-middleware-express": "^1.7.22", + "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 d250d79655f49..f3c55fb00ffb7 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 58b6d940dd1a0..d59604529ecbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11783,7 +11783,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==