我是 GrapQL 的新手。我正在尝试将它与弹簧靴一起使用。我可以成功进行查询,它正在返回我需要的数据,但我现在想使用变异。我需要在他注册时向数据库添加一个用途。
这是我的 schema.graphqls 文件:
type Token {
    token: String
}
type Register {
    message: String
}
type User {
    username: String!
    firstName: String!
    lastName: String!
    password: String!
    role: String!
}
type Query {
    login(username: String, password: String): Token
}
type Mutation {
    register(input: RegisterUserInput!): Register
}
input RegisterUserInput {
    username: String!
    firstName: String!
    lastName: String!
    password: String!
    role: String!
}
schema {
    query: Query
    mutation: Mutation
}
所以你可以看到 register 是 Mutation 类型,它和 Query 一样添加到模式中。但出于某种原因,它看起来没有进入 Mutation,它只是试图在 Query 中查找类型。
这是我的控制器: …