Postman GraphQL mutation variable as int

Hi, I have a question about Postman GraphQL mutations and using env variables in that mutation

Below is a part sample of mutation we use to delete an event, I have taken out most of the fields as they are not relevant for the question.

The way we use Postman for GraphQL is make it an HTTP request and select GraphQL as the body type

The way one of our developers set it up is to use the format below were we use the Query window in Postman and add all the content there as opposed to parameterizing the mutation and using the variables window. I believe this is through the data model at the API that requires it to be like this.

We have a field called eventTypeId that I would like to pass into the mutation, however Postman through as error: Int cannot represent non-integer value: “{{animalKey}}”

How can I use an env variable as an Int in this instance?

Thanks in advance

mutation {
  deleteEvent(
    inputModel: { clientId: "{{clientId}}",
     inputList: [{           
        eventTypeId: "{{eventTypeId}}",
        eventDate: "2024-03-10"
        eventName: "{{Longjump}}"
    }]}){
       result
  }
}

Hi @cryosat-operator-620.

Welcome to the Postman Community!

Variables in GraphQL are distinct and are different from variables in Postman. They work hand in hand to complement each other. You will notice that the GraphQL client has a seperate input field on the right for inserting GraphQL variables.

You will need to author GraphQL variables in your schema as you would if you were working with GraphQL in your client side code. Then use the GraphQL Variables tab I mentioned to inject Postman variables into your gql query.

Take the above screenshot for example, the gql variables were first declared and used in the schema. Then Postman variables are passed into this schema on RHS.

@gbadebo-bello

Thanks for your reply.

As I suspected our setup of the mutations and data models is not a traditional GraphQL approach.

Have passed the problem up the food chain for someone else to review.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.