Skip to content

Commit

Permalink
!82 [Improvement] 统一通过 GraphQLDocument#getOperation 获取 GraphQLOperation
Browse files Browse the repository at this point in the history
Merge pull request !82 from flytreeleft/bugfixes
  • Loading branch information
entropy-cloud authored and gitee-org committed Aug 22, 2024
2 parents cfd2daa + e36ec36 commit eb2b0e7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ public void initGraphQLContext(IGraphQLExecutionContext context, ParsedGraphQLRe
}
validateDocument(doc);

Map<String, Object> 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);

Expand All @@ -337,6 +336,8 @@ public void initGraphQLContext(IGraphQLExecutionContext context, ParsedGraphQLRe

context.setOperation(op);
context.setExecutionId(request.getOperationId());

Map<String, Object> vars = request.getVariables();
FieldSelectionBean selectionBean = buildSelectionBean(op.getName(), op.getSelectionSet(), vars);
context.setFieldSelection(selectionBean);
}
Expand Down Expand Up @@ -560,4 +561,4 @@ public CompletionStage<Object> fetchResult(Object result, IGraphQLExecutionConte
IGraphQLExecutor executor = new GraphQLExecutor(operationInvoker, graphQLHook, flowControlRunner, this);
return executor.fetchResult(result, context);
}
}
}

0 comments on commit eb2b0e7

Please sign in to comment.