From e36ec36320f690d7e3d52123470e8669865e58f3 Mon Sep 17 00:00:00 2001 From: flytreeleft Date: Sun, 18 Aug 2024 16:00:56 +0800 Subject: [PATCH] =?UTF-8?q?NopGraphQL:=20=E7=BB=9F=E4=B8=80=E9=80=9A?= =?UTF-8?q?=E8=BF=87=20GraphQLDocument#getOperation=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=20GraphQLOperation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/nop/graphql/core/engine/GraphQLEngine.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nop-graphql/nop-graphql-core/src/main/java/io/nop/graphql/core/engine/GraphQLEngine.java b/nop-graphql/nop-graphql-core/src/main/java/io/nop/graphql/core/engine/GraphQLEngine.java index b1b5e7d34..c9f8a703b 100644 --- a/nop-graphql/nop-graphql-core/src/main/java/io/nop/graphql/core/engine/GraphQLEngine.java +++ b/nop-graphql/nop-graphql-core/src/main/java/io/nop/graphql/core/engine/GraphQLEngine.java @@ -326,8 +326,7 @@ public void initGraphQLContext(IGraphQLExecutionContext context, ParsedGraphQLRe } validateDocument(doc); - Map vars = request.getVariables(); - GraphQLOperation op = (GraphQLOperation) doc.getDefinitions().get(0); + GraphQLOperation op = doc.getOperation(); if (op.getSelectionSet() == null || op.getSelectionSet().isEmpty()) throw new NopException(ERR_GRAPHQL_QUERY_NO_OPERATION); @@ -337,6 +336,8 @@ public void initGraphQLContext(IGraphQLExecutionContext context, ParsedGraphQLRe context.setOperation(op); context.setExecutionId(request.getOperationId()); + + Map vars = request.getVariables(); FieldSelectionBean selectionBean = buildSelectionBean(op.getName(), op.getSelectionSet(), vars); context.setFieldSelection(selectionBean); } @@ -560,4 +561,4 @@ public CompletionStage fetchResult(Object result, IGraphQLExecutionConte IGraphQLExecutor executor = new GraphQLExecutor(operationInvoker, graphQLHook, flowControlRunner, this); return executor.fetchResult(result, context); } -} \ No newline at end of file +}