【发布时间】:2021-11-18 05:23:59
【问题描述】:
在尝试使用 npm run schema:download 下载架构时,我收到以下错误。
my-app@0.1.0 架构:下载 npx apollo 服务:下载 --endpoint=http://localhost:9000/graphql ./src/app/graphql-schema.json
已弃用:此命令将从 apollo CLI 中删除
它的下一个主要版本。替换功能可在
新的 Apollo Rover CLI:https://go.apollo.dev/t/migration
✔ 正在加载 Apollo 项目 ✖ 将架构保存到 ./src/app/graphql-schema.json → 虚假结果。 错误:无法使用 GraphQLSchema "{ __validationErrors: undefined, extensions: undefined, astNode: 未定义,扩展ASTNodes:未定义,__allowedLegacyNames:[],_queryType:查询,_mutationType: 突变,_subscriptionType:null,_directives:[@include,@skip,@deprecated,@specifiedBy], _typeMap: { Query: Query, Car: Car, String: String, Float: Float, Mutation: Mutation, NewCarInput: NewCarInput,Int:Int,__Schema:__Schema,__Type:__Type,__TypeKind:__TypeKind,布尔:布尔, __Field:__Field,__InputValue:__InputValue,__EnumValue:__EnumValue,__Directive:__Directive, __DirectiveLocation: __DirectiveLocation }, _possibleTypeMap: {}, _implementations: {} }" 从另一个 模块或领域。
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.
我在 package.json 中提供了 schema:download 的端点,如下所示。
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"schema:download": "npx apollo service:download --endpoint=http://localhost:9000/graphql ./src/app/graphql-schema.json",
"schema:generate-watch": "npx apollo codegen:generate --localSchemaFile=./src/app/graphql-schema.json --target=typescript --tagName=gql --watch"
},
有人可以帮我解决这个问题,因为我是 graphql 的新手
【问题讨论】:
标签: reactjs graphql apollo-client