Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
position: Position,
filePath: Uri,
): Promise {
const graphQLConfig = this._graphQLRC.getConfigByFilePath(filePath);
if (!graphQLConfig) {
return null;
}
let ast;
try {
ast = parse(query);
} catch (error) {
return null;
}
const node = getASTNodeAtPosition(query, ast, position);
switch (node ? node.kind : null) {
case FRAGMENT_SPREAD:
return this._getDefinitionForFragmentSpread(
query,
ast,
node,
filePath,
graphQLConfig,
);
case FRAGMENT_DEFINITION:
case OPERATION_DEFINITION:
return getDefinitionQueryResultForDefinitionNode(
filePath,
query,
node,
);
async getDefinition(
query: string,
position: Position,
filePath: Uri,
): Promise {
const projectConfig = this.getConfigForURI(filePath);
let ast;
try {
ast = parse(query);
} catch (error) {
return null;
}
const node = getASTNodeAtPosition(query, ast, position);
if (node) {
switch (node.kind) {
case FRAGMENT_SPREAD:
return this._getDefinitionForFragmentSpread(
query,
ast,
node,
filePath,
projectConfig,
);
case FRAGMENT_DEFINITION:
case OPERATION_DEFINITION:
return getDefinitionQueryResultForDefinitionNode(
filePath,
query,