首页 > 解决方案 > 具有多个版本的 graphql 的 gatsby - 纱线分辨率

问题描述

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

但可能我在这里遗漏了一些东西..

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

非常感谢任何帮助。

标签: reactjsnpmgraphqlgatsby

解决方案


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

我创建了新的项目gatsby new <project_name>并做了npm install. 安装插件npm install --save gatsby-source-pg

在此之后,我搜索了名为graphqlin的文件夹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.

但现在,我可以使用GraphiQLPlayground 来执行我的 graphql 查询,也可以在项目中执行。

更新:

你可以最小化分辨率,然后说:

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

特别感谢 Postgraphile 的 @benji


推荐阅读