当我运行yarn run graphql-codegen --config codegen.yml时,我一直收到一个错误
错误说
Found 1 error
✖ src/generated/graphql.tsx
AggregateError: GraphQL Document Validation failed with 1 errors
at Object.checkValidationErrors (/home/tsatsralt/code/st/workspade/web/node_modules/@graphql-tools/utils/index.js:960:1
5)
at Object.codegen (/home/tsatsralt/code/st/workspade/web/node_modules/@graphql-codegen/core/index.cjs.js:102:15)
at async process (/home/tsatsralt/code/st/workspade/web/node_modules/@graphql-codegen/cli/bin.js:992:56)
at async Promise.all (index 0)
at async /home/tsatsralt/code/st/workspade/web/node_modules/@graphql-codegen/cli/bin.js:999:37
at async Task.task (/home/tsatsralt/code/st/workspade/web/node_modules/@graphql-codegen/cli/bin.js:778:17)codegen.yml
overwrite: true
schema: "http://localhost:4000/graphql"
documents: "src/graphql/**/*.graphql"
generates:
src/generated/graphql.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollosrc/graphql/突变/login.Graphql
mutation Login($loginPassword: String!, $loginEmail: String!) {
login(password: $loginPassword, email: $loginEmail) {
errors {
field
message
}
user {
...RegularUser
}
}
}用户解析器
@Resolver(User)
export class UserResolver {
@Mutation(() => UserResponse)
async login(
@Arg("email") email: string,
@Arg("password") password: string,
@Ctx() { req }: Context
): Promise<UserResponse> { logic }我完成了ben的14个小时的全堆栈教程,并决定做一个类似的项目。但我遇到了这个问题。在网上找不到有用的东西,所以我决定在这里问。
此外,我还拥有所需的所有依赖项。
发布于 2021-08-09 10:13:22
问题其实很愚蠢。让我解释一下我的错误:
使用graphql-codegen调试提示:
codegen并没有告诉你到底是什么导致了错误。试试看
Console.error(错误)发生错误的地方。在我的例子中,我认为
/home/tsatsralt/code/st/workspade/web/node_modules/@graphql-tools/utils/index.js这个错误很大程度上告诉了我出了什么问题。我得到的错误是
Variable "$input" of type "RegisterInput" used in position expecting type "RegisterInput!".我使用了一个名为RegisterInput的片段,忘记在register.graphql文件中添加感叹号。
希望我的错误也能帮到你。
https://stackoverflow.com/questions/68709347
复制相似问题