【问题标题】:argument Where of type xxxxxx is required, but it was not provided需要 xxxxxx 类型的参数,但未提供
【发布时间】:2021-02-05 11:23:55
【问题描述】:

我有这个奇怪的问题。也许我错过了什么

我有两张桌子,车辆和购买

当我尝试通过

查询车辆时
    query {
                vehicles{
          id
        }
    }

正常返回数据???

{
  "data": {
    "vehicles": [
      {
        "id": 29
      }
    ]
  }
}

但是有了这个查询

    query {
                purchase{
          id
        }
    }

我收到此错误

{
  "error": {
    "errors": [
      {
        "message": "Field \"purchase\" argument \"where\" of type \"purchaseWhereUniqueInput!\" is required, but it was not provided.",
        "locations": [
          {
            "line": 2,
            "column": 3
          }
        ],

这是我的代码:-

export const PaymentQuery =extendType({
  type :"Query",
  definition(t) {
    t.crud.purchase({filtering : true , pagination : true , ordering : true , })
  }
})

export const VehicleQuery = extendType({
  type : "Query",
  definition(t) {
    t.crud.vehicles({filtering : true , pagination : true , ordering : true , });
  }
})

【问题讨论】:

  • 拼写错误。应该是t.crud.purchases()

标签: apollo-server prisma prisma-graphql nexus-prisma


【解决方案1】:

我意识到 nexusjs 使用命名约定来确定查询是否应该返回一个列表!

将表名从purchase更改为purchases即可解决问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多