From f9e917f2eaab444b731ec07965eefa52a72d9602 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sat, 7 Oct 2023 14:35:31 +0100 Subject: [PATCH] Add 'unnamed' for the operations without the name. --- graphql.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphql.go b/graphql.go index 84157eb..f973578 100644 --- a/graphql.go +++ b/graphql.go @@ -34,7 +34,11 @@ func parseGraphQLQuery(c *fiber.Ctx) (operationType, operationName string, cache for _, d := range p.Definitions { if oper, ok := d.(*ast.OperationDefinition); ok { operationType = oper.Operation - operationName = oper.Name.Value + if oper.Name != nil { + operationName = oper.Name.Value + } else { + operationName = "undefined" + } for _, dir := range oper.Directives { if dir.Name.Value == "cached" { cacheRequest = true