Insomnia: [Bug] Cannot reference numeric Environment Variable values in GraphQL query variables

Created on 12 Feb 2020  路  13Comments  路  Source: Kong/insomnia

Describe the bug
When referencing an environment variable in GraphQL query variables, an environment variable that contains a JSON number both reports a JSON parse error in the query variables pane and results in a GraphQL error for invalid expected type of Int due to rendering as a string value.

To Reproduce
Steps to reproduce the behavior:

  1. Create an environment variable with a numeric value
  2. Create a GraphQL query using query variables
  3. Reference numeric environment variable in query variables
  4. See JSON parse error in Query Variables pane
  5. Send Query and (likely) receive type error

Expected behavior
Expect support for numeric JSON values in (Insomnia) environment variables. This may require the JSON parsing to interpret Nunjucks template markup before parsing to resolve parse error and to pass a numeric value when given one.

Screenshots
Screen Shot 2020-02-12 at 9 48 59 AM
Screen Shot 2020-02-12 at 9 51 52 AM

Desktop (please complete the following information):

  • OS: macOS 10.15.2
  • Installation Method: homebrew
  • App Version: v7.0.6
help wanted

All 13 comments

any update on this?

I'm hitting this problem as well I'm having to hardcode the value in, which defeats the purpose.

Getting the same issue with standard JSON POST request while evaluating this product.

Am i missing something or is this an issue with _numeric_ Environment Variables throughout Insomnia?

testIntEnvVar is defined in a Sub Environment:
"testIntEnvVar": 1234

image

EDIT:
Although this is just a linting error, the request POST's successfully and returns the desired result in this case.

@jkamleh , if you don't mind me asking, but what platform are you on?

What you wrote works fine for me. I'm on Mac OS 10.14
However, a coworker runs Windows 10, and it doesn't work for him.

We're both running Insomnia 7.1.1.

EDIT:
It doesn't actually work for me, it turned out that it was simply caching the previous query variables due to the linting error

@jostFT I鈥檓 running Windows 10 and encountered the issue on the latest downloadable release (unsure of the version number as I鈥檓 away from my workstation).

+1 馃憤

Getting the following errors:
Screen Shot 2020-05-18 at 11 43 32 AM
Screen Shot 2020-05-18 at 11 44 58 AM
Screen Shot 2020-05-18 at 11 43 42 AM

Confirmed on:

  • OS: macOS Mojave 10.14.6
  • Installation Method: Official Installer
  • App Version: 7.1.1 (7.1.1.3350)

The issue still persists in the latest version, 2020.2.1.
Insomnia can't handle numeric query variables correctly.
image

Previewing the User variable:
image

Any update on this?

Is this only specific to environment variables? Can Insomnia handle numeric variables coming from Request Body attribute?

If the data you're referencing comes from the result of another request, you can pull it out of the response body object as below.
The only downside to this that I noticed is that insomnia can't parse the JSON body correctly. However, the request is handled just as expected.

Using insomnia core 2020.3.3 on ubuntu 20.04

insomnia crop

@vino-jasuba Are you certain that it is not using your previous json body that had no parsing errors? That's what happened to me. I thought it worked, but it turned out that due to the parsing error, it simply referred to previous a json body that had no parsing errors.

+1 same issue, Macos Catalina 10.15.7
Version: Insomnia Core 2020.4.1

Same issue here. Adding a numeric environment variable / response variable to the query variables leads to invalid json, and it seems it does not really re-evaluate it.

Problem seems to be the way Insomnia handles the references:

{ "id": {% response 'body', 'req_fa61b45b7eeb4643ae0a4ce424d72abe', 'b64::JC5kYXRhLmFkZENhc2VEYXRhR3JvdXBUb0Nhc2UuY2FzZURhdGFHcm91cC5pZA==::46b', 'never', 60 %} }

Was this page helpful?
0 / 5 - 0 ratings