我运行时不断收到错误消息
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)
代码生成.yml
overwrite: true
schema: "http://localhost:4000/graphql"
documents: "src/graphql/**/*.graphql"
generates:
src/generated/graphql.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo
src/graphql/mutations/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 awad 的 14 小时全栈教程,并决定做一个类似的项目。但我遇到了这个问题。在互联网上找不到任何有用的东西,因此我决定在这里问。
我也有所有需要的依赖项