小编Ani*_*i T的帖子

带参数的 graphql 查询不适用于用户 ID

我被迷惑了。我最初创建了用户查询,它给了我错误,我认为是语法错误。但后来我创建了一个相同的车辆查询,效果非常好。我怀疑这和ID有关!类型,但我已经没有线索了。任何帮助,将不胜感激!

这是我的类型定义和解析器。

//类型定义//

   type User {
      id: ID!
      fname: String
      lname: String
      email: String
      password: String
      vehicles: [Vehicle]
    }

    type Vehicle {
      id: ID!
      vin: String
      model: String
      make: String
      drivers: [User]
    }

    type Query {
      users: [User]
      user(id: ID!): User
      vehicles: [Vehicle]
      vehicle(vin: String): Vehicle
    }
Run Code Online (Sandbox Code Playgroud)

//解析器//

   user: async (parent, args, context) => {
        const { id } = args
        return context.prisma.user.findUnique({
          where: {
            id,
          },
        })
      },
   vehicle: async (parent, args, context) => { …
Run Code Online (Sandbox Code Playgroud)

graphql prisma prisma-graphql prisma2

3
推荐指数
1
解决办法
5926
查看次数

标签 统计

graphql ×1

prisma ×1

prisma-graphql ×1

prisma2 ×1