···
} from 'graphql-language-service';
-
import { FragmentDefinitionNode, GraphQLSchema, Kind, parse } from 'graphql';
···
schema: { current: GraphQLSchema | null },
info: ts.server.PluginCreateInfo
): ts.WithMetadata<ts.CompletionInfo> | undefined {
const tagTemplate = info.config.template || 'gql';
const isCallExpression = info.config.templateIsCallExpression ?? false;
···
const queryText = node.arguments[0].getText();
const fragments = getAllFragments(filename, node, info);
-
const cursor = new Cursor(foundToken.line, foundToken.start);
-
const items = getAutocompleteSuggestions(
isGlobalCompletion: false,
isMemberCompletion: false,
isNewIdentifierLocation: false,
-
entries: items.map(suggestion => ({
-
kind: ts.ScriptElementKind.variableElement,
-
name: suggestion.label,
-
kindModifiers: 'declare',
-
sortText: suggestion.sortText || '0',
-
detail: suggestion.type
-
? ' ' + suggestion.type?.toString()
-
description: suggestion.documentation,
} else if (ts.isTaggedTemplateExpression(node)) {
const { template, tag } = node;
···
foundToken.line = foundToken.line + amountOfLines;
-
const cursor = new Cursor(foundToken.line, foundToken.start);
const [suggestions, spreadSuggestions] = getSuggestionsInternal(
···
} from 'graphql-language-service';
+
FragmentDefinitionNode,
···
schema: { current: GraphQLSchema | null },
info: ts.server.PluginCreateInfo
): ts.WithMetadata<ts.CompletionInfo> | undefined {
+
const logger: any = (msg: string) =>
+
info.project.projectService.logger.info(`[GraphQLSP] ${msg}`);
const tagTemplate = info.config.template || 'gql';
const isCallExpression = info.config.templateIsCallExpression ?? false;
···
const queryText = node.arguments[0].getText();
const fragments = getAllFragments(filename, node, info);
+
const cursor = new Cursor(foundToken.line, foundToken.start - 1);
+
const text = `${queryText}\m${fragments.map(x => print(x)).join('\n')}`;
+
const [suggestions, spreadSuggestions] = getSuggestionsInternal(
isGlobalCompletion: false,
isMemberCompletion: false,
isNewIdentifierLocation: false,
+
...suggestions.map(suggestion => ({
+
kind: ts.ScriptElementKind.variableElement,
+
name: suggestion.label,
+
kindModifiers: 'declare',
+
sortText: suggestion.sortText || '0',
+
detail: suggestion.type
+
? ' ' + suggestion.type?.toString()
+
description: suggestion.documentation,
+
...spreadSuggestions.map(suggestion => ({
+
kind: ts.ScriptElementKind.variableElement,
+
name: suggestion.label,
+
insertText: '...' + suggestion.label,
+
kindModifiers: 'declare',
+
description: suggestion.documentation,
} else if (ts.isTaggedTemplateExpression(node)) {
const { template, tag } = node;
···
foundToken.line = foundToken.line + amountOfLines;
+
const cursor = new Cursor(foundToken.line, foundToken.start - 1);
const [suggestions, spreadSuggestions] = getSuggestionsInternal(