确保node_modules目录中只有一个“graphql”实例

Dee*_*yan 6 reactjs graphql apollo-client

在尝试使用 npm run schema:download 下载架构时,我收到以下错误。

\n
\n

my-app@0.1.0 架构:download\nnpx apollo 服务:download --endpoint=http://localhost:9000/graphql ./src/app/graphql-schema.json

\n
\n
\n

apollo已弃用:此命令将在下一个主要版本中从 CLI 中删除。新的 Apollo Rover CLI 中提供了替换功能: https: //go.apollo.dev/t/migration

\n

\xe2\x9c\x94 正在加载 Apollo 项目\n\xe2\x9c\x96 将架构保存到 ./src/app/graphql-schema.json\n\xe2\x86\x92 虚假结果。\n错误:无法使用 GraphQLSchema "{ __validationErrors:未定义,扩展:未定义,astNode:\ n未定义,扩展ASTNodes:未定义,__allowedLegacyNames:[],_queryType:查询,_mutationType:\nMutation,_subscriptionType:null,_directives:[@include,@skip,@deprecated,@specifiedBy] ,\n_typeMap: { 查询: 查询, 汽车: 汽车, 字符串: 字符串, 浮点: 浮点, 突变: 突变, NewCarInput:\nNewCarInput, Int: Int, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, Boolean: Boolean, \n__Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive,\n__DirectiveLocation: __DirectiveLocation }, _possibleTypeMap: {}, _implementations: {} }" 来自另一个\n模块或领域。

\n
Ensure that there is only one instance of "graphql" in the node_modules\ndirectory. If different versions of "graphql" are the dependencies of other\nrelied on modules, use "resolutions" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate "graphql" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.\n
Run Code Online (Sandbox Code Playgroud)\n

我在 package.json 中提供了 schema:download 的端点,如下所示。

\n
  "scripts": {\n"start": "craco start",\n"build": "craco build",\n"test": "craco test",\n"eject": "react-scripts eject",\n"schema:download": "npx apollo service:download --endpoint=http://localhost:9000/graphql ./src/app/graphql-schema.json",\n"schema:generate-watch": "npx apollo codegen:generate --localSchemaFile=./src/app/graphql-schema.json --target=typescript --tagName=gql --watch"\n
Run Code Online (Sandbox Code Playgroud)\n

},

\n

有人可以帮我解决这个问题,因为我是 graphql 新手

\n

小智 5

我在 package.json 中将 graphql 切换到 v15.7.2,它对我有用。