Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby): handle graphql-import-node bundling #36951

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"got": "^11.8.5",
"graphql": "^16.6.0",
"graphql-compose": "^9.0.9",
"graphql-tag": "^2.12.6",
Copy link
Contributor Author

@pieh pieh Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already being installed transitively (codegen deps eventually install it), so it's not adding new dependency and just makes sure package managers install it in a way that can be resolved from within gatsby package

"hasha": "^5.2.2",
"invariant": "^2.2.4",
"is-relative": "^1.0.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ export async function createGraphqlEngineBundle(
test: /\.txt/,
type: `asset/resource`,
},
{
test: /\.(graphqls?|gqls?)$/,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to match const VALID_EXTENSIONS = ['graphql', 'graphqls', 'gql', 'gqls']; from graphql-import-node package, so it doesn't exactly match instructions for loader ( https://www.npmjs.com/package/graphql-tag#webpack-loading-and-preprocessing )

use: {
loader: require.resolve(`graphql-tag/loader`),
},
},
],
},
resolve: {
Expand All @@ -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: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// no-op
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down