Search code examples
graphqlransackgraphiql

Pass two same parameters in graphql


In GraphiQL, how to pass two same parameter using ransack? I want to get data where status not equal to "A" and "B"

 {
      invoice(
        q: {id_eq: 7, status_not_eq: "A",status_not_eq:"B"}
      ) {
        status
        paymentStatus
      }
    }

Error

"There can be only one input field named \"status_not_eq\""

Solution

  • As the error states, and considering what you have experienced yourself when querying the service with only one status_not_eq; and not being able to confirm it with the actual GraphQL contract, I conclude that this query admits only one status_not_eq per request.

    If you want to query with a different criteria (in this case, admitting an array of status_not_eq), the contract would need to change and the implementation would have to be coded (in case it doesn't exist).

    Today, somewhere in the schema for this query it says:

    ...
    tenancy_id_eq:Int, status_not_eq:String
    ...
    

    What you need to ask the backend team:

    ...
    tenancy_id_eq:Int, status_not_eq:[String]
    ...