带有graphql多个版本的gatsby-纱线分辨率

时间:2019-03-26 14:38:46

标签: reactjs npm graphql gatsby

我从盖茨比开始。尝试使用gatsby-source-pg插件。但是面临多个graphql版本的问题。我在github上问这个插件的作者这个问题,他在回答我的问题上非常有帮助。

但是也许我在这里缺少什么。

问题-https://github.com/graphile/gatsby-source-pg/issues/3

我们非常感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

啊..找出正确的版本是很棘手的..

我用gatsby new <project_name>创建了一个新项目,并做了npm install。 已安装npm install --save gatsby-source-pg

的插件

此后,我在graphql中搜索了名为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游乐场来执行我的graphql查询,也可以在项目中执行。

更新:

您可以将分辨率降至最低,而只需说:

"resolutions:" {
     "graphql": "14.x"
}

特别感谢Postgraphile的@benji

答案 1 :(得分:0)

运行npm list graphql

然后,检查找到的graphql的最高版本。

然后,将其添加到您的package.json

  "resolutions":{
    "graphql": "<highest found version>"
  }

然后,删除您的package-lock.jsonnode_modules文件夹。 运行npm install