From b30baeabc8ac96be3006b6d2d1ad1117cc4cc148 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Mon, 13 Jul 2020 20:43:35 +0100 Subject: [PATCH] Optionally match on operation name --- graphene_django/static/graphene_django/graphiql.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graphene_django/static/graphene_django/graphiql.js b/graphene_django/static/graphene_django/graphiql.js index 1240077..45f8ad7 100644 --- a/graphene_django/static/graphene_django/graphiql.js +++ b/graphene_django/static/graphene_django/graphiql.js @@ -135,7 +135,9 @@ // Run a regex against the query to determine the operation type (query, mutation, subscription). var operationRegex = new RegExp( // 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. "[^\\{]*\\{", // Enable multiline matching.