Use Environment variables inside of GraphQL variables

I’m trying to define GraphQL in the Body of a POST I’m making via Postman. An example of a valid “GraphQL Variables” section of my post is as follows:

    "buildingId": 8237,
    "accountId": 71

However, I’d like to specify environment variables in this section as well, since “buildingId” is going to vary between different environments. For example, I’d like my “GraphQL Variables” to look like this instead, where I can define “building_id” for each of my environments:

    "buildingId": {{building_id}},
    "accountId": {{account_id}}

Is there a way to accomplish this?

Hi @wfresch,

Welcome to the community! :clap:

From the looks of what you wrote, that is exactly the way you would accomplish it, same syntax and all. Difference is, that you create an environment for each of the environments you have, specify the variable with the same exact name, and give it its appropriate value. Then when you change environments, you will see that the variables’ value also changes.

If you need me to clarify more, I’d be more than happy to do so.


1 Like

It’s not letting me use environment variables inside of that GraphQL box. I use environment variables inside my route URLs and headers, but Postman doesn’t allow them inside of the GraphQL box. I’ll add a screenshot tomorrow.

Is this what you’re looking to do?

I’m just using the Pokemon GraphQL endpoint here to use as an example but the same should work for any other example.

My GraphQL Request Body:

query ($name: String!){
  pokemon(name: $name) {

My GraphQL Variable:

	"name": "{{name}}"

I just have a Global name variable set as Pikachu and once that request is sent, it’s picking that up and using that variable in the body.


Yes, I’m sorry. The variables DO actually work. It’s just that my current version (7.10.0) marks the variable names in red inside of the “GraphQL Variables” section, and it seemed like the variables were unrecognized. I also had some unnecessary quotes around an integer field, so that was a separate error altogether.