Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 4 tasks
cdreier opened this issue Jan 20, 2025 · 0 comments
Labels
B-bug Bug: general classification S-unverified Status: Unverified by maintainer

Comments

@cdreier
Copy link

cdreier commented Jan 20, 2025

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

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?

Which sync method do you use?

  • Git sync.
  • Insomnia Cloud sync.
  • 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

@cdreier cdreier added B-bug Bug: general classification S-unverified Status: Unverified by maintainer labels Jan 20, 2025
@cdreier cdreier changed the title Plugin: sendRequest calls in requestActions with templateTags change the request body to string Plugin: sendRequest calls in requestActions with templateTags change type of graphql variables in the request body to string Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-bug Bug: general classification S-unverified Status: Unverified by maintainer
Projects
None yet
Development

No branches or pull requests

1 participant