[GH-ISSUE #2211] [bug]: Graphql query function incorrectly formats proxy payload #757

Closed
opened 2026-03-16 17:03:21 +03:00 by kerem · 2 comments
Owner

Originally created by @cloudomatic on GitHub (Mar 28, 2022).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2211

Originally assigned to: @AndrewBastin on GitHub.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When going to the hoppscotch.io page and selecting "GraphQL", the default query works fine (with proxy disabled), and formats the payload as

  {
    "query": "query Request {\n  method\n  url\n  headers {\n    key\n    value\n  }\n}\n",
    "variables": {
      "id": "1"
    }
  }

However enabling the proxy causes the payload to be formatted as

  {
    "method": "post",
    "url": "https://echo.hoppscotch.io/graphql",
    "headers": {
        "content-type": "application/json"
    },
    "data": "{\"query\":\"query Request {\\n  method\\n  url\\n  headers {\\n    key\\n    value\\n  }\\n}\\n\",\"variables\":{\"id\":\"1\"}}",
    "params": {},
    "wantsBinary": true
  }

where the "data" attribute is a stringified JSON object, which the server rejects (error 400 - incorrect character at position zero), even though the headers show a content-type of "application/json".

My expectation is that since the content-type is application/json, the payload would be formed as a JSON object and not stringified JSON, with only the "query" attribute stringified (not the "data" attribute).

I get the same error when going to a GraphQL service on the self-hosted version, where the proxy is required because the GraphQL endpoint doesn't support cross-origin requests.

Steps to reproduce

  1. Go to https://hoppscotch.io
  2. Select the "graphql" menu option
  3. Enable the proxy using the default address under "settings"
  4. Click "run" on the default query.
  5. The error is HTTP 200 from proxyscotch with an embedded HTTP 400 error
  6. Disable the proxy and repeat step 4 and the query is successful.

Environment

Production

Version

Cloud

Originally created by @cloudomatic on GitHub (Mar 28, 2022). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2211 Originally assigned to: @AndrewBastin on GitHub. ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior When going to the hoppscotch.io page and selecting "GraphQL", the default query works fine (with proxy disabled), and formats the payload as ``` { "query": "query Request {\n method\n url\n headers {\n key\n value\n }\n}\n", "variables": { "id": "1" } } ``` However enabling the proxy causes the payload to be formatted as ``` { "method": "post", "url": "https://echo.hoppscotch.io/graphql", "headers": { "content-type": "application/json" }, "data": "{\"query\":\"query Request {\\n method\\n url\\n headers {\\n key\\n value\\n }\\n}\\n\",\"variables\":{\"id\":\"1\"}}", "params": {}, "wantsBinary": true } ``` where the "data" attribute is a stringified JSON object, which the server rejects (error 400 - incorrect character at position zero), even though the headers show a content-type of "application/json". My expectation is that since the content-type is application/json, the payload would be formed as a JSON object and not stringified JSON, with only the "query" attribute stringified (not the "data" attribute). I get the same error when going to a GraphQL service on the self-hosted version, where the proxy is required because the GraphQL endpoint doesn't support cross-origin requests. ### Steps to reproduce 1) Go to https://hoppscotch.io 2) Select the "graphql" menu option 3) Enable the proxy using the default address under "settings" 4) Click "run" on the default query. 5) The error is HTTP 200 from proxyscotch with an embedded HTTP 400 error 6) Disable the proxy and repeat step 4 and the query is successful. ### Environment Production ### Version Cloud
kerem 2026-03-16 17:03:21 +03:00
Author
Owner

@AndrewBastin commented on GitHub (Mar 29, 2022):

Hi @cloudomatic,

We will look into getting this implemented. Meanwhile, you can use the Hoppscotch Browser Extension as a workaround.

<!-- gh-comment-id:1081358262 --> @AndrewBastin commented on GitHub (Mar 29, 2022): Hi @cloudomatic, We will look into getting this implemented. Meanwhile, you can use the Hoppscotch Browser Extension as a workaround.
Author
Owner

@AndrewBastin commented on GitHub (Apr 18, 2022):

Fixed on 62a5beb.

Closing.

Thank you for reporting @cloudomatic!

<!-- gh-comment-id:1101542125 --> @AndrewBastin commented on GitHub (Apr 18, 2022): Fixed on [62a5beb](https://github.com/hoppscotch/hoppscotch/commit/62a5beb52f1e9fd382bb17de8029988cf56ed6f2). Closing. Thank you for reporting @cloudomatic!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#757
No description provided.