reactjs - 具有多个版本的 graphql 的 gatsby - 纱线分辨率
问题描述
我从盖茨比开始。尝试使用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
在此之后,我搜索了名为graphql
in的文件夹node_modules
,然后准备了以下解决方案列表 -
"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
推荐阅读
- c# - 具有多个类的递归树视图
- python - 如何检测数据集中的相同性或重复数据模式(python)
- angular - Angular - 升级到 v12 后无法访问 Material 主题功能
- android - 我正在创建一个食品订购应用程序。当我切换到暗模式时,应用程序崩溃了
- c - struct数组调用引用迭代问题
- sql - 尝试从 AD 检索描述字段时出错
- sql-server-2012 - 加入 Microsoft SQL Server 和 SQLite 表
- makefile - 有没有办法跳过 Makefile 中定义的几个包的安装?
- flutter - 在 Flutter 小部件测试中,我似乎无法找到一个小部件,即使我可以找到它的子级和父级
- css - 如何使用css从下到上渐变图像?