Skip to content

Import Postman GraphQL requests as a native GraphQL block (fixes voiden#490)#1

Open
rajkumar0932 wants to merge 1 commit into
VoidenHQ:mainfrom
rajkumar0932:fix/490-graphql-import
Open

Import Postman GraphQL requests as a native GraphQL block (fixes voiden#490)#1
rajkumar0932 wants to merge 1 commit into
VoidenHQ:mainfrom
rajkumar0932:fix/490-graphql-import

Conversation

@rajkumar0932

Copy link
Copy Markdown

What

GraphQL requests imported from a Postman collection were converted into a plain POST request block (method + URL) plus a detached query block — so the endpoint got stranded in its own POST block at the top of the file instead of inside the GraphQL block.

This emits a native gqlquery block instead, with:

  • the endpoint folded in as a gqlurl child,
  • the query as a gqlbody child (current format: body + operationType + schema* attrs),
  • a gqlvariables block when variables are present.

Non-GraphQL requests are unchanged.

Fixes VoidenHQ/voiden#490

Before / After

For a Postman GraphQL request, the importer previously produced:

request     (POST + endpoint URL)   ← stray, detached from the query
…headers…
gqlquery    (attrs.body = query)    ← old format, no endpoint
gqlvariables

Now it produces:

gqlquery
  ├─ gqlurl    (endpoint)
  └─ gqlbody   (query, operationType, schema*)
gqlvariables
…headers…

This matches the shape the app already expects: its old→new gqlquery migration converts to gqlurl + gqlbody, and GraphQL requests are detected via findNode("gqlquery").

Testing

  • node build.mjs builds cleanly (vite/esbuild).
  • Verified the converted structure for a GraphQL request (query + variables): a single gqlquery block containing the gqlurl endpoint and gqlbody, followed by a gqlvariables block, with no stray request/POST block; operationType is detected (reuses the existing detectGraphqlOperationType helper); REST requests still produce a normal request block.

The repo has no unit-test harness, so I validated the output against the app's canonical block format rather than adding a test suite — happy to add one if you'd like.

A GraphQL request was converted into a plain POST request block (method + URL)
plus a detached query block, leaving the endpoint stranded in its own POST block.

Emit a native gqlquery block instead, with the endpoint folded in as gqlurl and
the query as gqlbody (the current format), plus a gqlvariables block when
variables are present. Non-GraphQL requests are unchanged.

Fixes VoidenHQ/voiden#490

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rajkumar0932

Copy link
Copy Markdown
Author

Saw voiden#490 shipped in 2.2.0 via the converter fix in 424b904 (nice touches with the uid attrs and CRLF normalization) — glad the gqlquery/gqlurl approach made it in. Happy to close this since it's covered now, or rebase on v1.0.6 if any part is still useful.

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.

[Enhancement] [Low] GraphQL Import Uses Legacy POST Block Format

1 participant