graphql-parse-resolve-info: Import is causing issues with bundler

未关闭
#869 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
graphql, javascript, nextjs

调研方向

从 packages/graphql-parse-resolve-info/src/index.ts 第 20 行附近开始,使用 [email protected] 和 Next.js bundler 重现该问题。检查该包现有的测试或构建配置;当打包后的包不再触发重复的 GraphQL realm 错误,且相关检查通过时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Summary

Hello 👋 I'm using the graphql-parse-resolve-info package for a frontend project, which means it goes through a bundler (in my case that is Next.js). After upgrading my graphql version to 16.x I'm experiencing some weird errors that look like this:

Cannot use GraphQLScalarType "String" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

Of course I checked that I don't have duplicate graphql versions. In fact I could track this issue down to a line in this package:

https://github.com/graphile/graphile-engine/blob/e2a8a7cae58ff26947c050505c76c4a30cfe21c6/packages/graphql-parse-resolve-info/src/index.ts#L20

It looks like the issue is that getArgumentValues is not imported directly from graphql but rather from a sub-directory. I assume that is because it is only exposed since this commit: https://github.com/graphql/graphql-js/commit/6871bad65a7bdc0f9416f49944cd774f713cfb0b, which landed in version 16.4.0.

When I change this line to import directly from graphql, the error from above is gone. To be fair this is probably also caused by my bundler and using this package with a bundler is probably a niche use-case anyways.

Additional context

Relevant package versions:

主要语言
JavaScript
星标
764
派生
128
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphile/graphile-engine 的其他 Issue

查看 graphile/graphile-engine 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。