argument Where of type xxxxxx is required, but it was not provided

454 views Asked by At

I have this strange issue . maybe i missed something

i have two tables , Vehicles and purchases

when i try to query the vehicles via

    query {
                vehicles{
          id
        }
    }

It returns data normally

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

But with this query

    query {
                purchase{
          id
        }
    }

I recieve this error

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

here is my code : -

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 , });
  }
})
1

There are 1 answers

0
Ahmed Ahmed Sayed On

I realized that nexusjs use naming convention to determine if the query should return a list or not !

changing the table name from purchase to purchases solves the problem