Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.53k stars 1.95k forks source link

Insomnia does send graphql variables as a JSON string instead of an object #6900

Open penngrove opened 10 months ago

penngrove commented 10 months ago

Expected Behavior

expected the variables element in the JSON request to be an object with the variables

--data '{"query":"query test($id: [String!]!) {\n login {\n service(id: $id) {\n sessions {\n timestamp\n endpoint {\n proxy\n externalAddress\n version\n }\n target {\n id\n name\n device {\n name\n }\n }\n }\n }\n }\n}\n","operationName":"test","variables":{\"id\":\"80:00:00:00:01:0A:FA:90\"}}'

Actual Behavior

the variables are passed as the JSON string containing the variables

--data '{"query":"query test($id: [String!]!) {\n login {\n service(id: $id) {\n sessions {\n timestamp\n endpoint {\n proxy\n externalAddress\n version\n }\n target {\n id\n name\n device {\n name\n }\n }\n }\n }\n }\n}\n","operationName":"test","variables":"{\"id\":\"80:00:00:00:01:0A:FA:90\"}"}'

Note the quotes around "{\"id\":\"80:00:00:00:01:0A:FA:90\"}" making this a string

Reproduction Steps

setup a GraphQL query with variables, look at the code generated

Is there an existing issue for this?

Additional Information

No response

Insomnia Version

8.4.5

What operating system are you using?

macOS

Operating System Version

macOS 14.1.1 (23B81)

Installation method

from website

Last Known Working Insomnia version

8.4.2

gauravruhela07 commented 10 months ago

Hi @penngrove I want to work on this issue, can you please assign it to me? Thank you.

MPiccinato commented 7 months ago

Any update on this issue? Still experiencing it in 8.6.1 and 9.0.0 beta

fluidsonic commented 7 months ago

Ouch, this also got me after upgrading to Insomnia 8. For me so far, it only happens when the GraphQL request is triggered by a placeholder/reference in another request (non-GraphQL in my case). When I run the affected GraphQL request manually it works as expected.

fluidsonic commented 5 months ago

Workflows with request references are still broken completely for me due to this. Also in the latest version 8.6.1.

mdnorman commented 4 days ago

This is also affecting me. It was working fine with Apollo Server in a Lambda, but fails with the following error when using expressMiddleware.

`variables` in a POST body should be provided as an object, not a recursively JSON-encoded string."