Skip to content

fix: pass operation to serverFetchOptions and graphqlEndpoint in doGraphqlRequest - #83

Merged
dulnan merged 1 commit into
dulnan:mainfrom
GitVasiliy:fix/pass-operation-to-fetch-options-and-endpoint
Apr 9, 2026
Merged

dulnan merged 1 commit into
dulnan:mainfrom
GitVasiliy:fix/pass-operation-to-fetch-options-and-endpoint

Conversation

@GitVasiliy

Copy link
Copy Markdown
Contributor

doGraphqlRequest extracts operation from body.operation but passes null to both getEndpoint() and getFetchOptions(). This means serverFetchOptions and graphqlEndpoint callbacks always receive null as the operation parameter.

The bug was introduced in 3c03c29 where all callsites used null. Commit 648d472 ("pass operation and operationName to onServerResponse") fixed onServerResponse and onServerError but missed the other two.

Note: the upload handler (upload.ts) is not affected — it calls these functions directly and already passes operation correctly.

Changes

  • Pass operation instead of null to getEndpoint() and getFetchOptions() in doGraphqlRequest
  • Also use the already-extracted operationName local variable instead of body.operationName || null in the getFetchOptions call
  • Add test verifying operation is correctly forwarded for both queries and mutations

…quest

In doGraphqlRequest, the `operation` variable was correctly extracted
from `body.operation` (line 46) but `null` was passed to both
`getEndpoint()` and `getFetchOptions()` instead of the actual value.

This meant that `serverFetchOptions` and `graphqlEndpoint` callbacks
always received `null` as the `operation` parameter, making it
impossible to distinguish between queries and mutations in these hooks.

The bug was introduced in commit 3c03c29 (initial file creation) where
all four callsites used `null`. Commit 648d472 fixed `onServerResponse`
and `onServerError` but missed `getEndpoint` and `getFetchOptions`.

Note: the upload handler (upload.ts) was not affected — it calls
getEndpoint/getFetchOptions directly and already passes `operation`
correctly.

Also fixes a minor inconsistency where `getFetchOptions` used
`body.operationName || null` instead of the already-extracted
`operationName` local variable.
@dulnan
dulnan merged commit cc9da1a into dulnan:main Apr 9, 2026
1 check passed
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.

2 participants