Skip to content

feat: Add GraphQL variables support (#576)#1712

Open
deepak0x wants to merge 1 commit into
foss42:mainfrom
deepak0x:feat/graphql-variables-576
Open

feat: Add GraphQL variables support (#576)#1712
deepak0x wants to merge 1 commit into
foss42:mainfrom
deepak0x:feat/graphql-variables-576

Conversation

@deepak0x

@deepak0x deepak0x commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

PR Description

Adds GraphQL variables support to the request editor.

A dedicated JSON variables editor is shown below the query editor for GraphQL requests. Variables are stored as raw JSON text on HttpRequestModel and merged into the outgoing request body as a parsed JSON object under the standard "variables" key, e.g.:

{
  "query": "query($id: ID!) { user(id: $id) { name } }",
  "variables": { "id": "42" }
}

If the variables text is not valid JSON, the raw string is sent as-is so nothing is silently lost.

This follows the JSON-editor approach recommended by the maintainer on the issue (a simple JSON text editor like the JSON content-type body, rather than a form/key-value editor that parses and rebuilds types), which also keeps the door open for follow-ups like filters & mutations.

Changes

  • HttpRequestModel: new variables field + hasVariables getter (codegen regenerated).
  • getGraphQLBody: include parsed variables in the body when present.
  • Request body UI: labeled Query editor + JSON Variables editor for GraphQL.
  • Provider update(): thread variables through.
  • Unit tests for variables serialization (valid JSON, empty, invalid JSON).

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

  • Yes
  • No, and this is why: please replace this line with details on why tests have not been included

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

Closes foss42#576

Adds a JSON variables editor below the query editor for GraphQL
requests. Variables are stored as raw JSON text and merged into the
request body as a parsed JSON object under the "variables" key,
falling back to the raw string when the input is not valid JSON.
@deepak0x

deepak0x commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

@ashitaprasad @animator ready for review. This uses the JSON text editor approach you suggested on #576.

@deepak0x deepak0x mentioned this pull request Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQL Variables

1 participant