Kong / Kong/insomnia

Plugin: sendRequest calls in requestActions with templateTags change type of graphql variables in the request body to string

Open
#8,307 0 comments 0 reactions 0 assignees View on GitHub
B-bug S-unverified
Dominant language
TypeScript
Stars
40k
Forks
2.4k
Avg merge
2d 13h
Merged PRs (30d)
61

Description

### Expected Behavior

Plugin Code: https://gist.github.com/cdreier/89b9f52db2ba7bb13087d0f6f181062a

the call to `context.network.sendRequest` with `templateTags` should not change the data type of a graphql body - like a remplateTag in a normal "send request"

query:

```
mutation updateHash($id: ID!) {
updateContent(documentId: $id, data: {
hash: "reset"
}) {
documentId
}
}
```

variables (screenshot, as i am using the template tag):

![Image](https://github.com/user-attachments/assets/90ce2b70-3703-4d8a-9305-a347457a6c76)

raw request timeline body output:

```
{
"name": "DataOut",
"value": "{\n \"query\": \"mutation updateHash($id: ID!) {\\n\\tupdateContent(documentId: $id, data: {\\n\\t\\thash: \\\"reset\\\"\\n\\t}) {\\n\\t\\tdocumentId\\n\\t}\\n}\",\n \"operationName\": \"updateHash\",\n \"variables\": {\n \"id\": \"12345\"\n }\n}",
"timestamp": 1737383573953
}
```

evaluated variables:

```
\"variables\": {\n \"id\": \"12345\"\n }\n}",
```

the variables are correct rendered as object ✅

### Actual Behavior

when running the same request with my `requestActions` code, the body is evaluated as string

raw request timeline body output

```
{
"name": "DataOut",
"value": "{\"query\":\"mutation asdf($id: ID!) {\\n\\tupdateContent(documentId: $id, data: {\\n\\t\\thash: \\\"reset\\\"\\n\\t}) {\\n\\t\\tdocumentId\\n\\t}\\n}\",\"operationName\":\"asdf\",\"variables\":\"{\\n\\t\\\"id\\\": \\\"12345\\\"\\n}\"}",
"timestamp": 1737383223821
}
```

evaluated variables:

```
\"variables\":\"{\\n\\t\\\"id\\\": \\\"12345\\\"\\n}\"}",
```

as you can see, the variables are not longer an object and are rendered as string

### Reproduction Steps

1. write a plugin using templateTags and requestActions
2. use the templateTag in a graphql variable
3. run the request via normal "Send" button -> all OK
4. run the request via the requestAction -> invalid request body

### Is there an existing issue for this?

- [x] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.

### Which sync method do you use?

- [ ] Git sync.
- [ ] Insomnia Cloud sync.
- [x] Local only

### Additional Information

_No response_

### Insomnia Version

10.3.0

### What operating system are you using?

Other Linux

### Operating System Version

Linux fedora 6.12.7-200.fc41.x86_64

### Installation method

rpm download from github

### Last Known Working Insomnia version

worked fine in a version a few month back

Contributor guide

Open the contributing guide

Research direction

Start with the plugin code in the linked gist and trace context.network.sendRequest from requestActions when templateTags are evaluated, comparing it with the normal Send path. Reproduce the GraphQL request from the issue and verify that variables remain an object in the request body rather than becoming a string.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.