Optionally match on operation name

This commit is contained in:
Jonathan Kim 2020-07-13 20:43:35 +01:00
parent 587af8f608
commit b30baeabc8

View File

@ -135,7 +135,9 @@
// Run a regex against the query to determine the operation type (query, mutation, subscription). // Run a regex against the query to determine the operation type (query, mutation, subscription).
var operationRegex = new RegExp( var operationRegex = new RegExp(
// Look for lines that start with an operation keyword, ignoring whitespace. // Look for lines that start with an operation keyword, ignoring whitespace.
"^\\s*(query|mutation|subscription)\\s+" + "^\\s*(query|mutation|subscription)\\s*" +
// The operation keyword should be followed by whitespace and the operationName in the GraphQL parameters (if available).
(graphQLParams.operationName ? ("\\s+" + graphQLParams.operationName) : "") +
// The line should eventually encounter an opening curly brace. // The line should eventually encounter an opening curly brace.
"[^\\{]*\\{", "[^\\{]*\\{",
// Enable multiline matching. // Enable multiline matching.