in src/main/com/intellij/lang/jsgraphql/ui/GraphQLUIProjectService.java [355:415]
public void executeGraphQL(@NotNull Editor editor, @NotNull VirtualFile virtualFile) {
final GraphQLEndpointsModel endpointsModel = editor.getUserData(GRAPH_QL_ENDPOINTS_MODEL);
if (endpointsModel == null) {
return;
}
final GraphQLConfigEndpoint selectedEndpoint =
GraphQLIntrospectionUtil.promptForEnvVariables(myProject, endpointsModel.getSelectedItem());
if (selectedEndpoint == null || selectedEndpoint.getUrl() == null) {
return;
}
final GraphQLQueryContext context = GraphQLQueryContextHighlightVisitor.getQueryContextBufferAndHighlightUnused(editor);
Map<String, Object> requestData = new HashMap<>();
requestData.put("query", context.query);
try {
requestData.put("variables", getQueryVariables(editor));
}
catch (JsonSyntaxException jse) {
Editor errorEditor = editor.getUserData(GRAPH_QL_VARIABLES_EDITOR);
@NlsSafe String errorMessage = jse.getMessage();
if (errorEditor != null) {
errorEditor.getContentComponent().grabFocus();
final VirtualFile errorFile = FileDocumentManager.getInstance().getFile(errorEditor.getDocument());
if (errorFile != null) {
final List<CodeSmellInfo> errors = CodeSmellDetector.getInstance(myProject).findCodeSmells(
Collections.singletonList(errorFile));
for (CodeSmellInfo error : errors) {
errorMessage = error.getDescription();
errorEditor.getCaretModel().moveToOffset(error.getTextRange().getStartOffset());
break;
}
}
}
else {
errorEditor = editor;
}
final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
final JComponent label = HintUtil.createErrorLabel(
GraphQLBundle.message("graphql.hint.text.failed.to.parse.variables.as.json", errorMessage));
final LightweightHint lightweightHint = new LightweightHint(label);
final Point hintPosition = hintManager.getHintPosition(lightweightHint, errorEditor, HintManager.UNDER);
hintManager.showEditorHint(lightweightHint, editor, hintPosition, 0, 10000, false, HintManager.UNDER);
return;
}
String payload = createQueryJsonSerializer().toJson(requestData);
HttpUriRequest request = GraphQLQueryClient.getInstance(myProject).createRequest(selectedEndpoint, payload);
if (request == null) {
return;
}
//noinspection DialogTitleCapitalization
Task.Backgroundable task =
new Task.Backgroundable(myProject, GraphQLBundle.message("graphql.progress.title.executing.graphql"), false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
runQuery(editor, virtualFile, context, selectedEndpoint.getUrl(), request, selectedEndpoint);
}
};
ProgressManager.getInstance().run(task);
}