Skip to content

Commit

Permalink
Merge pull request #87 from drwetter/SearchGraphQLMutation
Browse files Browse the repository at this point in the history
Search graphql mutation
  • Loading branch information
Hannah-PortSwigger authored Feb 5, 2025
2 parents bdfc1f2 + c83c5d2 commit 727abe6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Filter/Proxy/HTTP/HighlightGraphQLMutations.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Bambda to highlight GraphQL Requests.
* @author drwetter (https://github.com/drwetter/)
*
* can be extended with an an embracing if-clause like
* if (requestResponse.request().method().equals("POST")) {
* }
**/


// trim some chars just to be sure. For parsing more e.g. JsonNode is better
var body = requestResponse.request().bodyToString().trim();

// written as regex so that it can be extended if needed
String graphqlRegexPattern = "query\":\"mutation";
Pattern graphqlPattern = Pattern.compile(graphqlRegexPattern);

Matcher graphqlMatcher = graphqlPattern.matcher(body);
if (graphqlMatcher.find()) {
requestResponse.annotations().setHighlightColor(HighlightColor.CYAN);
requestResponse.annotations().setNotes("mutation");
}

return true;

0 comments on commit 727abe6

Please sign in to comment.