具有多个版本的 graphql 的 gatsby - 纱线分辨率
gatsby with multiple versions of graphql - yarn resolutions
我从盖茨比开始。尝试使用 gatsby-source-pg
插件。但面临多个 graphql 版本的问题。我在 github 上向这个插件的作者询问了这个问题,他非常乐于回答我的问题。
但我可能遗漏了一些东西..
问题 - https://github.com/graphile/gatsby-source-pg/issues/3
非常感谢任何帮助。
啊..找到正确的版本是棘手的..
我用 gatsby new <project_name>
创建了新项目并做了 npm install
。
使用 npm install --save gatsby-source-pg
安装插件
之后我在node_modules
中搜索了名为graphql
的文件夹,然后准备了以下解决方案列表-
"resolutions":{
"eslint-plugin-graphql/graphql": "14.1.1",
"express-graphql/graphql": "14.1.1",
"graphql-tools/graphql": "14.1.1",
"apollo-link/graphql": "14.1.1",
"apollo-utilities/graphql": "14.1.1",
"gatsby-source-graphql/graphql": "14.1.1",
"gatsby-source-pg/graphql": "14.1.1",
"@types/graphql": "14.1.1"
}
但后来不知何故,当我 yarn install
时,@types
说它不喜欢 14.1.1
并提供了一系列版本。我从显示的列表中选择最新的 14.0.7
并继续安装。它仍然生成如下警告 -
yarn install
yarn install v1.12.3
info No lockfile found.
[1/4] Resolving packages...
Couldn't find any versions for "@types/graphql" that matches "14.1.1"
? Please choose a version of "@types/graphql" from this list: 14.0.7
warning Resolution field "graphql@14.1.1" is incompatible with requested version "graphql@0.13.x"
[2/4] Fetching packages...
info fsevents@1.2.7: The platform "win32" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "gatsby > express-graphql@0.6.12" has incorrect peer dependency "graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0".
warning "gatsby > eslint-plugin-graphql@2.1.1" has incorrect peer dependency "graphql@^0.12.0 || ^0.13.0".
warning "gatsby > graphql-tools@3.1.1" has incorrect peer dependency "graphql@^0.13.0".
warning "gatsby > pnp-webpack-plugin > ts-pnp@1.0.1" has unmet peer dependency "typescript@*".
warning "gatsby-source-pg > gatsby-source-graphql > apollo-link@1.2.1" has incorrect peer dependency "graphql@^0.11.3 || ^0.12.3 || ^0.13.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 37.83s.
但现在,我可以使用 GraphiQL
playground 来执行我的 graphql 查询,也可以在项目中执行。
更新:
您可以最小化分辨率并直接说:
"resolutions": {
"graphql": "14.x"
}
特别感谢来自 Postgraphile 的@benji
运行 npm list graphql
然后,检查您找到的 graphql 的最高版本。
之后,将此添加到您的 package.json
:
"resolutions":{
"graphql": "<highest found version>"
}
然后,删除您的 package-lock.json
和 node_modules
文件夹。
运行npm install
我从盖茨比开始。尝试使用 gatsby-source-pg
插件。但面临多个 graphql 版本的问题。我在 github 上向这个插件的作者询问了这个问题,他非常乐于回答我的问题。
但我可能遗漏了一些东西..
问题 - https://github.com/graphile/gatsby-source-pg/issues/3
非常感谢任何帮助。
啊..找到正确的版本是棘手的..
我用 gatsby new <project_name>
创建了新项目并做了 npm install
。
使用 npm install --save gatsby-source-pg
之后我在node_modules
中搜索了名为graphql
的文件夹,然后准备了以下解决方案列表-
"resolutions":{
"eslint-plugin-graphql/graphql": "14.1.1",
"express-graphql/graphql": "14.1.1",
"graphql-tools/graphql": "14.1.1",
"apollo-link/graphql": "14.1.1",
"apollo-utilities/graphql": "14.1.1",
"gatsby-source-graphql/graphql": "14.1.1",
"gatsby-source-pg/graphql": "14.1.1",
"@types/graphql": "14.1.1"
}
但后来不知何故,当我 yarn install
时,@types
说它不喜欢 14.1.1
并提供了一系列版本。我从显示的列表中选择最新的 14.0.7
并继续安装。它仍然生成如下警告 -
yarn install
yarn install v1.12.3
info No lockfile found.
[1/4] Resolving packages...
Couldn't find any versions for "@types/graphql" that matches "14.1.1"
? Please choose a version of "@types/graphql" from this list: 14.0.7
warning Resolution field "graphql@14.1.1" is incompatible with requested version "graphql@0.13.x"
[2/4] Fetching packages...
info fsevents@1.2.7: The platform "win32" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "gatsby > express-graphql@0.6.12" has incorrect peer dependency "graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0".
warning "gatsby > eslint-plugin-graphql@2.1.1" has incorrect peer dependency "graphql@^0.12.0 || ^0.13.0".
warning "gatsby > graphql-tools@3.1.1" has incorrect peer dependency "graphql@^0.13.0".
warning "gatsby > pnp-webpack-plugin > ts-pnp@1.0.1" has unmet peer dependency "typescript@*".
warning "gatsby-source-pg > gatsby-source-graphql > apollo-link@1.2.1" has incorrect peer dependency "graphql@^0.11.3 || ^0.12.3 || ^0.13.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 37.83s.
但现在,我可以使用 GraphiQL
playground 来执行我的 graphql 查询,也可以在项目中执行。
更新:
您可以最小化分辨率并直接说:
"resolutions": {
"graphql": "14.x"
}
特别感谢来自 Postgraphile 的@benji
运行 npm list graphql
然后,检查您找到的 graphql 的最高版本。
之后,将此添加到您的 package.json
:
"resolutions":{
"graphql": "<highest found version>"
}
然后,删除您的 package-lock.json
和 node_modules
文件夹。
运行npm install