Skip to content

fix(rules): match GraphQL operationName in query params on GET requests - #119

Open
Abhishek-B-R wants to merge 1 commit into
requestly:masterfrom
Abhishek-B-R:fix/graphql-get-payload-matching
Open

fix(rules): match GraphQL operationName in query params on GET requests#119
Abhishek-B-R wants to merge 1 commit into
requestly:masterfrom
Abhishek-B-R:fix/graphql-get-payload-matching

Conversation

@Abhishek-B-R

Copy link
Copy Markdown

What this fixes

GraphQL rules that target an operationName did not apply to GET GraphQL requests. Fixes #35.

Root cause

Request payload filters (the mechanism behind GraphQL operationName targeting) only read the parsed request body. GET GraphQL requests carry no body: the operationName lives in the URL query string. So the matcher's body lookup came back empty and the filter never matched. The traffic table already reads GQL details from query params for GET requests (getGraphQLDetails in harLogs/utils.ts), the rule matcher just did not.

The fix

For GET and HEAD requests with no body, derive the payload object from the URL query params and match against that, mirroring getGraphQLDetails. POST keeps reading the body, so existing behavior is unchanged. The same change is applied in both matchers, the extension (ruleMatcher.ts) and the shared rule-processor (RuleHelper.js), so the extension and desktop app behave the same.

Tests

Added 3 cases to RuleHelper.spec.js: a GET request whose operationName is in the query params matches, a different operationName does not match, and a POST request still matches via the body.

Note on running the suite: the karma tests currently fail on a fresh clean checkout of master with Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization, a webpack 5 circular dependency that surfaces under node 22. This change does not touch that. To get a real before and after signal I validated the RuleHelper logic with a small standalone harness: before the change the GET and HEAD cases fail, after it they pass, and the POST body path is unchanged. Happy to send that webpack test setup fix as a separate small PR if it helps, keeping this one scoped to #35.

Request payload filters (used for GraphQL operationName targeting) only
read the parsed request body, so they never matched GET GraphQL requests
where the operationName lives in the URL query string. For GET/HEAD
requests with no body, derive the payload object from the query params,
mirroring how getGraphQLDetails in harLogs/utils.ts reads GQL details
from the query string. The same fix is applied in both the extension
matcher (ruleMatcher.ts) and the shared rule-processor matcher
(RuleHelper.js) so the extension and desktop app behave the same.

Fixes requestly#35
@CLAassistant

CLAassistant commented Sep 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

bug: modify response/request rule does not work in GET GraphQL requests

2 participants