Socket
Socket
Sign inDemoInstall

graphql-language-service

Package Overview
Dependencies
Maintainers
13
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service - npm Package Compare versions

Comparing version 5.0.5 to 5.0.6-canary-4bf7a139.0

4

dist/interface/autocompleteUtils.js

@@ -29,3 +29,3 @@ "use strict";

}
if (fieldName === introspection_1.TypeNameMetaFieldDef.name && graphql_1.isCompositeType(type)) {
if (fieldName === introspection_1.TypeNameMetaFieldDef.name && (0, graphql_1.isCompositeType)(type)) {
return introspection_1.TypeNameMetaFieldDef;

@@ -42,3 +42,3 @@ }

let state = stack;
while (state && state.kind) {
while (state === null || state === void 0 ? void 0 : state.kind) {
reverseStateStack.push(state);

@@ -45,0 +45,0 @@ state = state.prevState;

@@ -17,3 +17,3 @@ "use strict";

try {
graphql_2.visit(graphql_2.parse(op), {
(0, graphql_2.visit)((0, graphql_2.parse)(op), {
FragmentDefinition(def) {

@@ -42,3 +42,3 @@ externalFragments.push(def);

if (kind === parser_1.RuleKinds.DOCUMENT) {
return autocompleteUtils_1.hintList(token, [
return (0, autocompleteUtils_1.hintList)(token, [
{ label: 'query', kind: vscode_languageserver_types_1.CompletionItemKind.Function },

@@ -65,3 +65,3 @@ { label: 'mutation', kind: vscode_languageserver_types_1.CompletionItemKind.Function },

if (argDefs) {
return autocompleteUtils_1.hintList(token, argDefs.map((argDef) => {
return (0, autocompleteUtils_1.hintList)(token, argDefs.map((argDef) => {
var _a;

@@ -83,7 +83,7 @@ return ({

if (typeInfo.objectFieldDefs) {
const objectFields = autocompleteUtils_1.objectValues(typeInfo.objectFieldDefs);
const objectFields = (0, autocompleteUtils_1.objectValues)(typeInfo.objectFieldDefs);
const completionKind = kind === parser_1.RuleKinds.OBJECT_VALUE
? vscode_languageserver_types_1.CompletionItemKind.Value
: vscode_languageserver_types_1.CompletionItemKind.Field;
return autocompleteUtils_1.hintList(token, objectFields.map(field => {
return (0, autocompleteUtils_1.hintList)(token, objectFields.map(field => {
var _a;

@@ -107,5 +107,5 @@ return ({

if (kind === parser_1.RuleKinds.VARIABLE && step === 1) {
const namedInputType = graphql_2.getNamedType(typeInfo.inputType);
const namedInputType = (0, graphql_2.getNamedType)(typeInfo.inputType);
const variableDefinitions = getVariableCompletions(queryText, schema, token);
return autocompleteUtils_1.hintList(token, variableDefinitions.filter(v => v.detail === (namedInputType === null || namedInputType === void 0 ? void 0 : namedInputType.name)));
return (0, autocompleteUtils_1.hintList)(token, variableDefinitions.filter(v => v.detail === (namedInputType === null || namedInputType === void 0 ? void 0 : namedInputType.name)));
}

@@ -141,13 +141,13 @@ if ((kind === parser_1.RuleKinds.TYPE_CONDITION && step === 1) ||

const type = field.type;
if (graphql_2.isCompositeType(type)) {
if ((0, graphql_2.isCompositeType)(type)) {
return insertSuffix;
}
if (graphql_1.isListType(type) && graphql_2.isCompositeType(type.ofType)) {
if ((0, graphql_1.isListType)(type) && (0, graphql_2.isCompositeType)(type.ofType)) {
return insertSuffix;
}
if (graphql_1.isNonNullType(type)) {
if (graphql_2.isCompositeType(type.ofType)) {
if ((0, graphql_1.isNonNullType)(type)) {
if ((0, graphql_2.isCompositeType)(type.ofType)) {
return insertSuffix;
}
if (graphql_1.isListType(type.ofType) && graphql_2.isCompositeType(type.ofType.ofType)) {
if ((0, graphql_1.isListType)(type.ofType) && (0, graphql_2.isCompositeType)(type.ofType.ofType)) {
return insertSuffix;

@@ -164,5 +164,5 @@ }

if ('getFields' in parentType) {
fields = autocompleteUtils_1.objectValues(parentType.getFields());
fields = (0, autocompleteUtils_1.objectValues)(parentType.getFields());
}
if (graphql_2.isCompositeType(parentType)) {
if ((0, graphql_2.isCompositeType)(parentType)) {
fields.push(graphql_2.TypeNameMetaFieldDef);

@@ -173,3 +173,3 @@ }

}
return autocompleteUtils_1.hintList(token, fields.map((field, index) => {
return (0, autocompleteUtils_1.hintList)(token, fields.map((field, index) => {
var _a;

@@ -199,7 +199,7 @@ const suggestion = {

function getSuggestionsForInputValues(token, typeInfo, queryText, schema) {
const namedInputType = graphql_2.getNamedType(typeInfo.inputType);
const namedInputType = (0, graphql_2.getNamedType)(typeInfo.inputType);
const queryVariables = getVariableCompletions(queryText, schema, token).filter(v => v.detail === namedInputType.name);
if (namedInputType instanceof graphql_2.GraphQLEnumType) {
const values = namedInputType.getValues();
return autocompleteUtils_1.hintList(token, values
return (0, autocompleteUtils_1.hintList)(token, values
.map((value) => {

@@ -221,3 +221,3 @@ var _a;

else if (namedInputType === graphql_2.GraphQLBoolean) {
return autocompleteUtils_1.hintList(token, queryVariables.concat([
return (0, autocompleteUtils_1.hintList)(token, queryVariables.concat([
{

@@ -246,3 +246,3 @@ label: 'true',

const typeMap = schema.getTypeMap();
const schemaInterfaces = autocompleteUtils_1.objectValues(typeMap).filter(graphql_1.isInterfaceType);
const schemaInterfaces = (0, autocompleteUtils_1.objectValues)(typeMap).filter(graphql_1.isInterfaceType);
const schemaInterfaceNames = schemaInterfaces.map(({ name }) => name);

@@ -295,3 +295,3 @@ const inlineInterfaces = new Set();

!siblingInterfaceNames.includes(name));
return autocompleteUtils_1.hintList(token, possibleInterfaces.map(type => {
return (0, autocompleteUtils_1.hintList)(token, possibleInterfaces.map(type => {
const result = {

@@ -311,4 +311,4 @@ label: type.name,

if (typeInfo.parentType) {
if (graphql_2.isAbstractType(typeInfo.parentType)) {
const abstractType = graphql_2.assertAbstractType(typeInfo.parentType);
if ((0, graphql_2.isAbstractType)(typeInfo.parentType)) {
const abstractType = (0, graphql_2.assertAbstractType)(typeInfo.parentType);
const possibleObjTypes = schema.getPossibleTypes(abstractType);

@@ -321,3 +321,3 @@ const possibleIfaceMap = Object.create(null);

});
possibleTypes = possibleObjTypes.concat(autocompleteUtils_1.objectValues(possibleIfaceMap));
possibleTypes = possibleObjTypes.concat((0, autocompleteUtils_1.objectValues)(possibleIfaceMap));
}

@@ -330,9 +330,9 @@ else {

const typeMap = schema.getTypeMap();
possibleTypes = autocompleteUtils_1.objectValues(typeMap).filter(graphql_2.isCompositeType);
possibleTypes = (0, autocompleteUtils_1.objectValues)(typeMap).filter(graphql_2.isCompositeType);
}
return autocompleteUtils_1.hintList(token, possibleTypes.map(type => {
const namedType = graphql_2.getNamedType(type);
return (0, autocompleteUtils_1.hintList)(token, possibleTypes.map(type => {
const namedType = (0, graphql_2.getNamedType)(type);
return {
label: String(type),
documentation: (namedType && namedType.description) || '',
documentation: (namedType === null || namedType === void 0 ? void 0 : namedType.description) || '',
kind: vscode_languageserver_types_1.CompletionItemKind.Field,

@@ -347,3 +347,3 @@ };

const typeMap = schema.getTypeMap();
const defState = autocompleteUtils_1.getDefinitionState(token.state);
const defState = (0, autocompleteUtils_1.getDefinitionState)(token.state);
const fragments = getFragmentDefinitions(queryText);

@@ -357,6 +357,6 @@ if (fragmentDefs && fragmentDefs.length > 0) {

defState.name === frag.name.value) &&
graphql_2.isCompositeType(typeInfo.parentType) &&
graphql_2.isCompositeType(typeMap[frag.typeCondition.name.value]) &&
graphql_2.doTypesOverlap(schema, typeInfo.parentType, typeMap[frag.typeCondition.name.value]));
return autocompleteUtils_1.hintList(token, relevantFrags.map(frag => ({
(0, graphql_2.isCompositeType)(typeInfo.parentType) &&
(0, graphql_2.isCompositeType)(typeMap[frag.typeCondition.name.value]) &&
(0, graphql_2.doTypesOverlap)(schema, typeInfo.parentType, typeMap[frag.typeCondition.name.value]));
return (0, autocompleteUtils_1.hintList)(token, relevantFrags.map(frag => ({
label: frag.name.value,

@@ -412,3 +412,3 @@ detail: String(typeMap[frag.typeCondition.name.value]),

});
return autocompleteUtils_1.objectValues(definitions);
return (0, autocompleteUtils_1.objectValues)(definitions);
}

@@ -447,4 +447,4 @@ exports.getVariableCompletions = getVariableCompletions;

const inputTypeMap = schema.getTypeMap();
const inputTypes = autocompleteUtils_1.objectValues(inputTypeMap).filter(graphql_2.isInputType);
return autocompleteUtils_1.hintList(token, inputTypes.map((type) => ({
const inputTypes = (0, autocompleteUtils_1.objectValues)(inputTypeMap).filter(graphql_2.isInputType);
return (0, autocompleteUtils_1.hintList)(token, inputTypes.map((type) => ({
label: type.name,

@@ -456,7 +456,8 @@ documentation: type.description,

function getSuggestionsForDirective(token, state, schema, _kind) {
if (state.prevState && state.prevState.kind) {
var _a;
if ((_a = state.prevState) === null || _a === void 0 ? void 0 : _a.kind) {
const directives = schema
.getDirectives()
.filter(directive => canUseDirective(state.prevState, directive));
return autocompleteUtils_1.hintList(token, directives.map(directive => ({
return (0, autocompleteUtils_1.hintList)(token, directives.map(directive => ({
label: directive.name,

@@ -494,3 +495,3 @@ documentation: directive.description || '',

const lines = queryText.split('\n');
const parser = parser_1.onlineParser();
const parser = (0, parser_1.onlineParser)();
let state = parser.startState();

@@ -523,2 +524,3 @@ let style = '';

function canUseDirective(state, directive) {
var _a;
if (!state || !state.kind) {

@@ -564,3 +566,3 @@ return false;

case parser_1.RuleKinds.INPUT_VALUE_DEF:
const prevStateKind = state.prevState && state.prevState.kind;
const prevStateKind = (_a = state.prevState) === null || _a === void 0 ? void 0 : _a.kind;
switch (prevStateKind) {

@@ -588,3 +590,4 @@ case parser_1.RuleKinds.ARGUMENTS_DEF:

let interfaceDef;
autocompleteUtils_1.forEachState(tokenState, state => {
(0, autocompleteUtils_1.forEachState)(tokenState, state => {
var _a;
switch (state.kind) {

@@ -614,3 +617,3 @@ case parser_1.RuleKinds.QUERY:

fieldDef = parentType
? autocompleteUtils_1.getFieldDef(schema, parentType, state.name)
? (0, autocompleteUtils_1.getFieldDef)(schema, parentType, state.name)
: null;

@@ -622,3 +625,3 @@ type = fieldDef ? fieldDef.type : null;

case parser_1.RuleKinds.SELECTION_SET:
parentType = graphql_2.getNamedType(type);
parentType = (0, graphql_2.getNamedType)(type);
break;

@@ -662,3 +665,3 @@ case parser_1.RuleKinds.DIRECTIVE:

case parser_1.RuleKinds.ALIASED_FIELD: {
const name = state.prevState && state.prevState.name;
const name = (_a = state.prevState) === null || _a === void 0 ? void 0 : _a.name;
if (!name) {

@@ -669,3 +672,3 @@ argDefs = null;

const field = parentType
? autocompleteUtils_1.getFieldDef(schema, parentType, name)
? (0, autocompleteUtils_1.getFieldDef)(schema, parentType, name)
: null;

@@ -695,6 +698,6 @@ if (!field) {

}
inputType = argDef && argDef.type;
inputType = argDef === null || argDef === void 0 ? void 0 : argDef.type;
break;
case parser_1.RuleKinds.ENUM_VALUE:
const enumType = graphql_2.getNamedType(inputType);
const enumType = (0, graphql_2.getNamedType)(inputType);
enumValue =

@@ -708,3 +711,3 @@ enumType instanceof graphql_2.GraphQLEnumType

case parser_1.RuleKinds.LIST_VALUE:
const nullableType = graphql_2.getNullableType(inputType);
const nullableType = (0, graphql_2.getNullableType)(inputType);
inputType =

@@ -714,3 +717,3 @@ nullableType instanceof graphql_2.GraphQLList ? nullableType.ofType : null;

case parser_1.RuleKinds.OBJECT_VALUE:
const objectType = graphql_2.getNamedType(inputType);
const objectType = (0, graphql_2.getNamedType)(inputType);
objectFieldDefs =

@@ -723,3 +726,3 @@ objectType instanceof graphql_2.GraphQLInputObjectType

const objectField = state.name && objectFieldDefs ? objectFieldDefs[state.name] : null;
inputType = objectField && objectField.type;
inputType = objectField === null || objectField === void 0 ? void 0 : objectField.type;
break;

@@ -726,0 +729,0 @@ case parser_1.RuleKinds.NAMED_TYPE:

@@ -23,3 +23,3 @@ "use strict";

assert(location, 'Expected ASTNode to have a location.');
return utils_1.locToRange(text, location);
return (0, utils_1.locToRange)(text, location);
}

@@ -29,3 +29,3 @@ function getPosition(text, node) {

assert(location, 'Expected ASTNode to have a location.');
return utils_1.offsetToPosition(text, location.start);
return (0, utils_1.offsetToPosition)(text, location.start);
}

@@ -32,0 +32,0 @@ function getDefinitionQueryResultForNamedType(text, node, dependencies) {

@@ -5,6 +5,6 @@ import { DocumentNode, FragmentDefinitionNode, GraphQLSchema, SourceLocation, ValidationRule } from 'graphql';

export declare const SEVERITY: {
Error: "Error";
Warning: "Warning";
Information: "Information";
Hint: "Hint";
readonly Error: "Error";
readonly Warning: "Warning";
readonly Information: "Information";
readonly Hint: "Hint";
};

@@ -11,0 +11,0 @@ export declare type Severity = typeof SEVERITY;

@@ -26,2 +26,3 @@ "use strict";

function getDiagnostics(query, schema = null, customRules, isRelayCompatMode, externalFragments) {
var _a, _b;
let ast = null;

@@ -36,3 +37,3 @@ if (externalFragments) {

externalFragments.reduce((agg, node) => {
agg += graphql_1.print(node) + '\n\n';
agg += (0, graphql_1.print)(node) + '\n\n';
return agg;

@@ -43,14 +44,17 @@ }, '');

try {
ast = graphql_2.parse(query);
ast = (0, graphql_2.parse)(query);
}
catch (error) {
const range = getRange(error.locations[0], query);
return [
{
severity: exports.DIAGNOSTIC_SEVERITY.Error,
message: error.message,
source: 'GraphQL: Syntax',
range,
},
];
if (error instanceof graphql_1.GraphQLError) {
const range = getRange((_b = (_a = error.locations) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : { line: 0, column: 0 }, query);
return [
{
severity: exports.DIAGNOSTIC_SEVERITY.Error,
message: error.message,
source: 'GraphQL: Syntax',
range,
},
];
}
throw error;
}

@@ -64,4 +68,4 @@ return validateQuery(ast, schema, customRules, isRelayCompatMode);

}
const validationErrorAnnotations = mapCat(utils_1.validateWithCustomRules(schema, ast, customRules, isRelayCompatMode), error => annotations(error, exports.DIAGNOSTIC_SEVERITY.Error, 'Validation'));
const deprecationWarningAnnotations = mapCat(graphql_1.validate(schema, ast, [graphql_1.NoDeprecatedCustomRule]), error => annotations(error, exports.DIAGNOSTIC_SEVERITY.Warning, 'Deprecation'));
const validationErrorAnnotations = mapCat((0, utils_1.validateWithCustomRules)(schema, ast, customRules, isRelayCompatMode), error => annotations(error, exports.DIAGNOSTIC_SEVERITY.Error, 'Validation'));
const deprecationWarningAnnotations = mapCat((0, graphql_1.validate)(schema, ast, [graphql_1.NoDeprecatedCustomRule]), error => annotations(error, exports.DIAGNOSTIC_SEVERITY.Warning, 'Deprecation'));
return validationErrorAnnotations.concat(deprecationWarningAnnotations);

@@ -100,3 +104,3 @@ }

function getRange(location, queryText) {
const parser = parser_1.onlineParser();
const parser = (0, parser_1.onlineParser)();
const state = parser.startState();

@@ -103,0 +107,0 @@ const lines = queryText.split('\n');

@@ -7,3 +7,3 @@ "use strict";

function getHoverInformation(schema, queryText, cursor, contextToken, config) {
const token = contextToken || getAutocompleteSuggestions_1.getTokenAtPosition(queryText, cursor);
const token = contextToken || (0, getAutocompleteSuggestions_1.getTokenAtPosition)(queryText, cursor);
if (!schema || !token || !token.state) {

@@ -15,3 +15,3 @@ return '';

const step = state.step;
const typeInfo = getAutocompleteSuggestions_1.getTypeInfo(schema, token.state);
const typeInfo = (0, getAutocompleteSuggestions_1.getTypeInfo)(schema, token.state);
const options = Object.assign(Object.assign({}, config), { schema });

@@ -18,0 +18,0 @@ if ((kind === 'Field' && step === 0 && typeInfo.fieldDef) ||

@@ -27,3 +27,3 @@ "use strict";

try {
ast = graphql_1.parse(documentText);
ast = (0, graphql_1.parse)(documentText);
}

@@ -34,3 +34,3 @@ catch (error) {

const visitorFns = outlineTreeConverter(documentText);
const outlineTrees = graphql_1.visit(ast, {
const outlineTrees = (0, graphql_1.visit)(ast, {
leave(node) {

@@ -50,4 +50,4 @@ if (visitorFns !== undefined && node.kind in visitorFns) {

representativeName: node.name,
startPosition: utils_1.offsetToPosition(docText, node.loc.start),
endPosition: utils_1.offsetToPosition(docText, node.loc.end),
startPosition: (0, utils_1.offsetToPosition)(docText, node.loc.start),
endPosition: (0, utils_1.offsetToPosition)(docText, node.loc.end),
kind: node.kind,

@@ -54,0 +54,0 @@ children: node.selectionSet || node.fields || node.values || node.arguments || [],

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -59,3 +59,3 @@ "use strict";

match = this._sourceText.slice(this._pos).match(pattern);
token = match && match[0];
token = match === null || match === void 0 ? void 0 : match[0];
}

@@ -62,0 +62,0 @@ if (match != null) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -33,2 +33,3 @@ "use strict";

function getToken(stream, state, options) {
var _a;
if (state.inBlockstring) {

@@ -53,3 +54,3 @@ if (stream.match(/.*"""/)) {

if (stream.sol()) {
const tabSize = (editorConfig && editorConfig.tabSize) || 2;
const tabSize = (editorConfig === null || editorConfig === void 0 ? void 0 : editorConfig.tabSize) || 2;
state.indentLevel = Math.floor(stream.indentation() / tabSize);

@@ -97,3 +98,3 @@ }

if (state.needsSeperator) {
expected = expected && (expected === null || expected === void 0 ? void 0 : expected.separator);
expected = expected === null || expected === void 0 ? void 0 : expected.separator;
}

@@ -108,3 +109,3 @@ if (expected) {

}
if (expected.match && expected.match(token)) {
if ((_a = expected.match) === null || _a === void 0 ? void 0 : _a.call(expected, token)) {
if (expected.update) {

@@ -164,2 +165,3 @@ expected.update(state, token);

function advanceRule(state, successful) {
var _a;
if (isList(state) && state.rule) {

@@ -185,3 +187,3 @@ const step = state.rule[state.step];

if (isList(state)) {
if (state.rule && state.rule[state.step].separator) {
if ((_a = state.rule) === null || _a === void 0 ? void 0 : _a[state.step].separator) {
state.needsSeperator = !state.needsSeperator;

@@ -188,0 +190,0 @@ }

@@ -22,3 +22,3 @@ "use strict";

exports.ParseRules = {
Document: [RuleHelpers_1.list('Definition')],
Document: [(0, RuleHelpers_1.list)('Definition')],
Definition(token) {

@@ -59,5 +59,5 @@ switch (token.value) {

word('query'),
RuleHelpers_1.opt(name('def')),
RuleHelpers_1.opt('VariableDefinitions'),
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.opt)(name('def')),
(0, RuleHelpers_1.opt)('VariableDefinitions'),
(0, RuleHelpers_1.list)('Directive'),
'SelectionSet',

@@ -67,5 +67,5 @@ ],

word('mutation'),
RuleHelpers_1.opt(name('def')),
RuleHelpers_1.opt('VariableDefinitions'),
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.opt)(name('def')),
(0, RuleHelpers_1.opt)('VariableDefinitions'),
(0, RuleHelpers_1.list)('Directive'),
'SelectionSet',

@@ -75,12 +75,12 @@ ],

word('subscription'),
RuleHelpers_1.opt(name('def')),
RuleHelpers_1.opt('VariableDefinitions'),
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.opt)(name('def')),
(0, RuleHelpers_1.opt)('VariableDefinitions'),
(0, RuleHelpers_1.list)('Directive'),
'SelectionSet',
],
VariableDefinitions: [RuleHelpers_1.p('('), RuleHelpers_1.list('VariableDefinition'), RuleHelpers_1.p(')')],
VariableDefinition: ['Variable', RuleHelpers_1.p(':'), 'Type', RuleHelpers_1.opt('DefaultValue')],
Variable: [RuleHelpers_1.p('$', 'variable'), name('variable')],
DefaultValue: [RuleHelpers_1.p('='), 'Value'],
SelectionSet: [RuleHelpers_1.p('{'), RuleHelpers_1.list('Selection'), RuleHelpers_1.p('}')],
VariableDefinitions: [(0, RuleHelpers_1.p)('('), (0, RuleHelpers_1.list)('VariableDefinition'), (0, RuleHelpers_1.p)(')')],
VariableDefinition: ['Variable', (0, RuleHelpers_1.p)(':'), 'Type', (0, RuleHelpers_1.opt)('DefaultValue')],
Variable: [(0, RuleHelpers_1.p)('$', 'variable'), name('variable')],
DefaultValue: [(0, RuleHelpers_1.p)('='), 'Value'],
SelectionSet: [(0, RuleHelpers_1.p)('{'), (0, RuleHelpers_1.list)('Selection'), (0, RuleHelpers_1.p)('}')],
Selection(token, stream) {

@@ -97,21 +97,21 @@ return token.value === '...'

name('property'),
RuleHelpers_1.p(':'),
(0, RuleHelpers_1.p)(':'),
name('qualifier'),
RuleHelpers_1.opt('Arguments'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.opt('SelectionSet'),
(0, RuleHelpers_1.opt)('Arguments'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.opt)('SelectionSet'),
],
Field: [
name('property'),
RuleHelpers_1.opt('Arguments'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.opt('SelectionSet'),
(0, RuleHelpers_1.opt)('Arguments'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.opt)('SelectionSet'),
],
Arguments: [RuleHelpers_1.p('('), RuleHelpers_1.list('Argument'), RuleHelpers_1.p(')')],
Argument: [name('attribute'), RuleHelpers_1.p(':'), 'Value'],
FragmentSpread: [RuleHelpers_1.p('...'), name('def'), RuleHelpers_1.list('Directive')],
Arguments: [(0, RuleHelpers_1.p)('('), (0, RuleHelpers_1.list)('Argument'), (0, RuleHelpers_1.p)(')')],
Argument: [name('attribute'), (0, RuleHelpers_1.p)(':'), 'Value'],
FragmentSpread: [(0, RuleHelpers_1.p)('...'), name('def'), (0, RuleHelpers_1.list)('Directive')],
InlineFragment: [
RuleHelpers_1.p('...'),
RuleHelpers_1.opt('TypeCondition'),
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.p)('...'),
(0, RuleHelpers_1.opt)('TypeCondition'),
(0, RuleHelpers_1.list)('Directive'),
'SelectionSet',

@@ -121,5 +121,5 @@ ],

word('fragment'),
RuleHelpers_1.opt(RuleHelpers_1.butNot(name('def'), [word('on')])),
(0, RuleHelpers_1.opt)((0, RuleHelpers_1.butNot)(name('def'), [word('on')])),
'TypeCondition',
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.list)('Directive'),
'SelectionSet',

@@ -158,7 +158,7 @@ ],

},
NumberValue: [RuleHelpers_1.t('Number', 'number')],
NumberValue: [(0, RuleHelpers_1.t)('Number', 'number')],
StringValue: [
{
style: 'string',
match: token => token.kind === 'String',
match: (token) => token.kind === 'String',
update(state, token) {

@@ -171,22 +171,22 @@ if (token.value.startsWith('"""')) {

],
BooleanValue: [RuleHelpers_1.t('Name', 'builtin')],
NullValue: [RuleHelpers_1.t('Name', 'keyword')],
BooleanValue: [(0, RuleHelpers_1.t)('Name', 'builtin')],
NullValue: [(0, RuleHelpers_1.t)('Name', 'keyword')],
EnumValue: [name('string-2')],
ListValue: [RuleHelpers_1.p('['), RuleHelpers_1.list('Value'), RuleHelpers_1.p(']')],
ObjectValue: [RuleHelpers_1.p('{'), RuleHelpers_1.list('ObjectField'), RuleHelpers_1.p('}')],
ObjectField: [name('attribute'), RuleHelpers_1.p(':'), 'Value'],
ListValue: [(0, RuleHelpers_1.p)('['), (0, RuleHelpers_1.list)('Value'), (0, RuleHelpers_1.p)(']')],
ObjectValue: [(0, RuleHelpers_1.p)('{'), (0, RuleHelpers_1.list)('ObjectField'), (0, RuleHelpers_1.p)('}')],
ObjectField: [name('attribute'), (0, RuleHelpers_1.p)(':'), 'Value'],
Type(token) {
return token.value === '[' ? 'ListType' : 'NonNullType';
},
ListType: [RuleHelpers_1.p('['), 'Type', RuleHelpers_1.p(']'), RuleHelpers_1.opt(RuleHelpers_1.p('!'))],
NonNullType: ['NamedType', RuleHelpers_1.opt(RuleHelpers_1.p('!'))],
ListType: [(0, RuleHelpers_1.p)('['), 'Type', (0, RuleHelpers_1.p)(']'), (0, RuleHelpers_1.opt)((0, RuleHelpers_1.p)('!'))],
NonNullType: ['NamedType', (0, RuleHelpers_1.opt)((0, RuleHelpers_1.p)('!'))],
NamedType: [type('atom')],
Directive: [RuleHelpers_1.p('@', 'meta'), name('meta'), RuleHelpers_1.opt('Arguments')],
Directive: [(0, RuleHelpers_1.p)('@', 'meta'), name('meta'), (0, RuleHelpers_1.opt)('Arguments')],
DirectiveDef: [
word('directive'),
RuleHelpers_1.p('@', 'meta'),
(0, RuleHelpers_1.p)('@', 'meta'),
name('meta'),
RuleHelpers_1.opt('ArgumentsDef'),
(0, RuleHelpers_1.opt)('ArgumentsDef'),
word('on'),
RuleHelpers_1.list('DirectiveLocation', RuleHelpers_1.p('|')),
(0, RuleHelpers_1.list)('DirectiveLocation', (0, RuleHelpers_1.p)('|')),
],

@@ -196,42 +196,42 @@ InterfaceDef: [

name('atom'),
RuleHelpers_1.opt('Implements'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.p('{'),
RuleHelpers_1.list('FieldDef'),
RuleHelpers_1.p('}'),
(0, RuleHelpers_1.opt)('Implements'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.p)('{'),
(0, RuleHelpers_1.list)('FieldDef'),
(0, RuleHelpers_1.p)('}'),
],
Implements: [word('implements'), RuleHelpers_1.list('NamedType', RuleHelpers_1.p('&'))],
Implements: [word('implements'), (0, RuleHelpers_1.list)('NamedType', (0, RuleHelpers_1.p)('&'))],
DirectiveLocation: [name('string-2')],
SchemaDef: [
word('schema'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.p('{'),
RuleHelpers_1.list('OperationTypeDef'),
RuleHelpers_1.p('}'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.p)('{'),
(0, RuleHelpers_1.list)('OperationTypeDef'),
(0, RuleHelpers_1.p)('}'),
],
OperationTypeDef: [name('keyword'), RuleHelpers_1.p(':'), name('atom')],
ScalarDef: [word('scalar'), name('atom'), RuleHelpers_1.list('Directive')],
OperationTypeDef: [name('keyword'), (0, RuleHelpers_1.p)(':'), name('atom')],
ScalarDef: [word('scalar'), name('atom'), (0, RuleHelpers_1.list)('Directive')],
ObjectTypeDef: [
word('type'),
name('atom'),
RuleHelpers_1.opt('Implements'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.p('{'),
RuleHelpers_1.list('FieldDef'),
RuleHelpers_1.p('}'),
(0, RuleHelpers_1.opt)('Implements'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.p)('{'),
(0, RuleHelpers_1.list)('FieldDef'),
(0, RuleHelpers_1.p)('}'),
],
FieldDef: [
name('property'),
RuleHelpers_1.opt('ArgumentsDef'),
RuleHelpers_1.p(':'),
(0, RuleHelpers_1.opt)('ArgumentsDef'),
(0, RuleHelpers_1.p)(':'),
'Type',
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.list)('Directive'),
],
ArgumentsDef: [RuleHelpers_1.p('('), RuleHelpers_1.list('InputValueDef'), RuleHelpers_1.p(')')],
ArgumentsDef: [(0, RuleHelpers_1.p)('('), (0, RuleHelpers_1.list)('InputValueDef'), (0, RuleHelpers_1.p)(')')],
InputValueDef: [
name('attribute'),
RuleHelpers_1.p(':'),
(0, RuleHelpers_1.p)(':'),
'Type',
RuleHelpers_1.opt('DefaultValue'),
RuleHelpers_1.list('Directive'),
(0, RuleHelpers_1.opt)('DefaultValue'),
(0, RuleHelpers_1.list)('Directive'),
],

@@ -241,5 +241,5 @@ UnionDef: [

name('atom'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.p('='),
RuleHelpers_1.list('UnionMember', RuleHelpers_1.p('|')),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.p)('='),
(0, RuleHelpers_1.list)('UnionMember', (0, RuleHelpers_1.p)('|')),
],

@@ -250,15 +250,15 @@ UnionMember: ['NamedType'],

name('atom'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.p('{'),
RuleHelpers_1.list('EnumValueDef'),
RuleHelpers_1.p('}'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.p)('{'),
(0, RuleHelpers_1.list)('EnumValueDef'),
(0, RuleHelpers_1.p)('}'),
],
EnumValueDef: [name('string-2'), RuleHelpers_1.list('Directive')],
EnumValueDef: [name('string-2'), (0, RuleHelpers_1.list)('Directive')],
InputDef: [
word('input'),
name('atom'),
RuleHelpers_1.list('Directive'),
RuleHelpers_1.p('{'),
RuleHelpers_1.list('InputValueDef'),
RuleHelpers_1.p('}'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.p)('{'),
(0, RuleHelpers_1.list)('InputValueDef'),
(0, RuleHelpers_1.p)('}'),
],

@@ -287,3 +287,4 @@ ExtendDef: [word('extend'), 'ObjectTypeDef'],

update(state, token) {
if (state.prevState && state.prevState.prevState) {
var _a;
if ((_a = state.prevState) === null || _a === void 0 ? void 0 : _a.prevState) {
state.name = token.value;

@@ -290,0 +291,0 @@ state.prevState.prevState.type = token.value;

@@ -12,3 +12,3 @@ "use strict";

variableDefinitions.forEach(({ variable, type }) => {
const inputType = graphql_1.typeFromAST(schema, type);
const inputType = (0, graphql_1.typeFromAST)(schema, type);
if (inputType) {

@@ -15,0 +15,0 @@ variableToType[variable.name.value] = inputType;

@@ -15,3 +15,3 @@ "use strict";

try {
parsedOperation = graphql_1.parse(operationString);
parsedOperation = (0, graphql_1.parse)(operationString);
}

@@ -21,3 +21,3 @@ catch (error) {

}
return exports.getFragmentDependenciesForAST(parsedOperation, fragmentDefinitions);
return (0, exports.getFragmentDependenciesForAST)(parsedOperation, fragmentDefinitions);
};

@@ -31,3 +31,3 @@ exports.getFragmentDependencies = getFragmentDependencies;

const referencedFragNames = new Set();
graphql_1.visit(parsedOperation, {
(0, graphql_1.visit)(parsedOperation, {
FragmentDefinition(node) {

@@ -45,3 +45,3 @@ existingFrags.set(node.name.value, true);

if (!existingFrags.has(name) && fragmentDefinitions.has(name)) {
asts.add(nullthrows_1.default(fragmentDefinitions.get(name)));
asts.add((0, nullthrows_1.default)(fragmentDefinitions.get(name)));
}

@@ -51,7 +51,7 @@ });

asts.forEach(ast => {
graphql_1.visit(ast, {
(0, graphql_1.visit)(ast, {
FragmentSpread(node) {
if (!referencedFragNames.has(node.name.value) &&
fragmentDefinitions.get(node.name.value)) {
asts.add(nullthrows_1.default(fragmentDefinitions.get(node.name.value)));
asts.add((0, nullthrows_1.default)(fragmentDefinitions.get(node.name.value)));
referencedFragNames.add(node.name.value);

@@ -58,0 +58,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

let nodeContainingPosition;
graphql_1.visit(ast, {
(0, graphql_1.visit)(ast, {
enter(node) {

@@ -11,0 +11,0 @@ if (node.kind !== 'Name' &&

@@ -8,6 +8,6 @@ "use strict";

const variableToType = schema
? collectVariables_1.collectVariables(schema, documentAST)
? (0, collectVariables_1.collectVariables)(schema, documentAST)
: undefined;
const operations = [];
graphql_1.visit(documentAST, {
(0, graphql_1.visit)(documentAST, {
OperationDefinition(node) {

@@ -25,3 +25,3 @@ operations.push(node);

try {
const documentAST = graphql_1.parse(documentString);
const documentAST = (0, graphql_1.parse)(documentString);
return Object.assign(Object.assign({}, getOperationASTFacts(documentAST, schema)), { documentAST });

@@ -28,0 +28,0 @@ }

@@ -12,7 +12,7 @@ "use strict";

function renderType(into, t) {
if (graphql_1.isNonNullType(t)) {
if ((0, graphql_1.isNonNullType)(t)) {
renderType(into, t.ofType);
text(into, '!');
}
else if (graphql_1.isListType(t)) {
else if ((0, graphql_1.isListType)(t)) {
text(into, '[');

@@ -53,10 +53,10 @@ renderType(into, t.ofType);

}
if (graphql_1.isEnumType(type)) {
if ((0, graphql_1.isEnumType)(type)) {
definition.type = 'string';
definition.enum = type.getValues().map(val => val.name);
}
if (graphql_1.isScalarType(type)) {
if ((0, graphql_1.isScalarType)(type)) {
definition.type = (_a = scalarTypesMap[type.name]) !== null && _a !== void 0 ? _a : 'any';
}
if (graphql_1.isListType(type)) {
if ((0, graphql_1.isListType)(type)) {
definition.type = 'array';

@@ -76,3 +76,3 @@ const { definition: def, definitions: defs } = getJSONSchemaFromGraphQLType(type.ofType, options);

}
if (graphql_1.isNonNullType(type)) {
if ((0, graphql_1.isNonNullType)(type)) {
required = true;

@@ -87,3 +87,3 @@ const { definition: def, definitions: defs } = getJSONSchemaFromGraphQLType(type.ofType, options);

}
if (graphql_1.isInputObjectType(type)) {
if ((0, graphql_1.isInputObjectType)(type)) {
definition.$ref = `#/definitions/${type.name}`;

@@ -136,3 +136,3 @@ const fields = type.getFields();

if ('description' in type &&
!graphql_1.isScalarType(type) &&
!(0, graphql_1.isScalarType)(type) &&
type.description &&

@@ -139,0 +139,0 @@ !definition.description) {

@@ -35,3 +35,3 @@ "use strict";

}
const errors = graphql_1.validate(schema, ast, rules);
const errors = (0, graphql_1.validate)(schema, ast, rules);
return errors.filter(error => {

@@ -38,0 +38,0 @@ if (error.message.indexOf('Unknown directive') !== -1 && error.nodes) {

@@ -36,3 +36,3 @@ import { isCompositeType } from 'graphql';

let state = stack;
while (state && state.kind) {
while (state === null || state === void 0 ? void 0 : state.kind) {
reverseStateStack.push(state);

@@ -39,0 +39,0 @@ state = state.prevState;

@@ -318,3 +318,3 @@ import { CompletionItemKind, InsertTextFormat, } from 'vscode-languageserver-types';

label: String(type),
documentation: (namedType && namedType.description) || '',
documentation: (namedType === null || namedType === void 0 ? void 0 : namedType.description) || '',
kind: CompletionItemKind.Field,

@@ -432,3 +432,4 @@ };

function getSuggestionsForDirective(token, state, schema, _kind) {
if (state.prevState && state.prevState.kind) {
var _a;
if ((_a = state.prevState) === null || _a === void 0 ? void 0 : _a.kind) {
const directives = schema

@@ -496,2 +497,3 @@ .getDirectives()

export function canUseDirective(state, directive) {
var _a;
if (!state || !state.kind) {

@@ -537,3 +539,3 @@ return false;

case RuleKinds.INPUT_VALUE_DEF:
const prevStateKind = state.prevState && state.prevState.kind;
const prevStateKind = (_a = state.prevState) === null || _a === void 0 ? void 0 : _a.kind;
switch (prevStateKind) {

@@ -561,2 +563,3 @@ case RuleKinds.ARGUMENTS_DEF:

forEachState(tokenState, state => {
var _a;
switch (state.kind) {

@@ -632,3 +635,3 @@ case RuleKinds.QUERY:

case RuleKinds.ALIASED_FIELD: {
const name = state.prevState && state.prevState.name;
const name = (_a = state.prevState) === null || _a === void 0 ? void 0 : _a.name;
if (!name) {

@@ -664,3 +667,3 @@ argDefs = null;

}
inputType = argDef && argDef.type;
inputType = argDef === null || argDef === void 0 ? void 0 : argDef.type;
break;

@@ -690,3 +693,3 @@ case RuleKinds.ENUM_VALUE:

const objectField = state.name && objectFieldDefs ? objectFieldDefs[state.name] : null;
inputType = objectField && objectField.type;
inputType = objectField === null || objectField === void 0 ? void 0 : objectField.type;
break;

@@ -693,0 +696,0 @@ case RuleKinds.NAMED_TYPE:

@@ -5,6 +5,6 @@ import { DocumentNode, FragmentDefinitionNode, GraphQLSchema, SourceLocation, ValidationRule } from 'graphql';

export declare const SEVERITY: {
Error: "Error";
Warning: "Warning";
Information: "Information";
Hint: "Hint";
readonly Error: "Error";
readonly Warning: "Warning";
readonly Information: "Information";
readonly Hint: "Hint";
};

@@ -11,0 +11,0 @@ export declare type Severity = typeof SEVERITY;

@@ -1,2 +0,2 @@

import { print, validate, NoDeprecatedCustomRule, } from 'graphql';
import { GraphQLError, print, validate, NoDeprecatedCustomRule, } from 'graphql';
import { parse } from 'graphql';

@@ -23,2 +23,3 @@ import { CharacterStream, onlineParser } from '../parser';

export function getDiagnostics(query, schema = null, customRules, isRelayCompatMode, externalFragments) {
var _a, _b;
let ast = null;

@@ -42,11 +43,14 @@ if (externalFragments) {

catch (error) {
const range = getRange(error.locations[0], query);
return [
{
severity: DIAGNOSTIC_SEVERITY.Error,
message: error.message,
source: 'GraphQL: Syntax',
range,
},
];
if (error instanceof GraphQLError) {
const range = getRange((_b = (_a = error.locations) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : { line: 0, column: 0 }, query);
return [
{
severity: DIAGNOSTIC_SEVERITY.Error,
message: error.message,
source: 'GraphQL: Syntax',
range,
},
];
}
throw error;
}

@@ -53,0 +57,0 @@ return validateQuery(ast, schema, customRules, isRelayCompatMode);

@@ -57,3 +57,3 @@ export default class CharacterStream {

match = this._sourceText.slice(this._pos).match(pattern);
token = match && match[0];
token = match === null || match === void 0 ? void 0 : match[0];
}

@@ -60,0 +60,0 @@ if (match != null) {

@@ -30,2 +30,3 @@ import { LexRules, ParseRules, isIgnored } from './Rules';

function getToken(stream, state, options) {
var _a;
if (state.inBlockstring) {

@@ -50,3 +51,3 @@ if (stream.match(/.*"""/)) {

if (stream.sol()) {
const tabSize = (editorConfig && editorConfig.tabSize) || 2;
const tabSize = (editorConfig === null || editorConfig === void 0 ? void 0 : editorConfig.tabSize) || 2;
state.indentLevel = Math.floor(stream.indentation() / tabSize);

@@ -94,3 +95,3 @@ }

if (state.needsSeperator) {
expected = expected && (expected === null || expected === void 0 ? void 0 : expected.separator);
expected = expected === null || expected === void 0 ? void 0 : expected.separator;
}

@@ -105,3 +106,3 @@ if (expected) {

}
if (expected.match && expected.match(token)) {
if ((_a = expected.match) === null || _a === void 0 ? void 0 : _a.call(expected, token)) {
if (expected.update) {

@@ -161,2 +162,3 @@ expected.update(state, token);

function advanceRule(state, successful) {
var _a;
if (isList(state) && state.rule) {

@@ -182,3 +184,3 @@ const step = state.rule[state.step];

if (isList(state)) {
if (state.rule && state.rule[state.step].separator) {
if ((_a = state.rule) === null || _a === void 0 ? void 0 : _a[state.step].separator) {
state.needsSeperator = !state.needsSeperator;

@@ -185,0 +187,0 @@ }

@@ -152,3 +152,3 @@ import { opt, list, butNot, t, p } from './RuleHelpers';

style: 'string',
match: token => token.kind === 'String',
match: (token) => token.kind === 'String',
update(state, token) {

@@ -273,3 +273,4 @@ if (token.value.startsWith('"""')) {

update(state, token) {
if (state.prevState && state.prevState.prevState) {
var _a;
if ((_a = state.prevState) === null || _a === void 0 ? void 0 : _a.prevState) {
state.name = token.value;

@@ -276,0 +277,0 @@ state.prevState.prevState.type = token.value;

{
"name": "graphql-language-service",
"version": "5.0.5",
"version": "5.0.6-canary-4bf7a139.0",
"description": "The official, runtime independent Language Service for GraphQL",

@@ -47,3 +47,3 @@ "contributors": [

"ts-node": "^8.10.2",
"typescript": "^4.1.3"
"typescript": "^4.6.3"
},

@@ -50,0 +50,0 @@ "scripts": {

@@ -12,3 +12,3 @@ /**

import fs, { readSync } from 'fs';
import fs from 'fs';
import {

@@ -15,0 +15,0 @@ buildSchema,

@@ -73,3 +73,3 @@ /**

let state: State | null | undefined = stack;
while (state && state.kind) {
while (state?.kind) {
reverseStateStack.push(state);

@@ -76,0 +76,0 @@ state = state.prevState;

@@ -62,3 +62,2 @@ /**

RuleKind,
_RuleKinds,
ContextTokenForCodeMirror,

@@ -565,3 +564,3 @@ } from '../parser';

label: String(type),
documentation: (namedType && namedType.description) || '',
documentation: namedType?.description || '',
kind: CompletionItemKind.Field,

@@ -743,3 +742,3 @@ };

): Array<CompletionItem> {
if (state.prevState && state.prevState.kind) {
if (state.prevState?.kind) {
const directives = schema

@@ -888,3 +887,3 @@ .getDirectives()

case RuleKinds.INPUT_VALUE_DEF:
const prevStateKind = state.prevState && state.prevState.kind;
const prevStateKind = state.prevState?.kind;
switch (prevStateKind) {

@@ -996,3 +995,3 @@ case RuleKinds.ARGUMENTS_DEF:

case RuleKinds.ALIASED_FIELD: {
const name = state.prevState && state.prevState.name;
const name = state.prevState?.name;
if (!name) {

@@ -1028,3 +1027,3 @@ argDefs = null;

}
inputType = argDef && argDef.type;
inputType = argDef?.type;
break;

@@ -1058,3 +1057,3 @@ // TODO: needs tests

state.name && objectFieldDefs ? objectFieldDefs[state.name] : null;
inputType = objectField && objectField.type;
inputType = objectField?.type;

@@ -1061,0 +1060,0 @@ break;

@@ -37,7 +37,7 @@ /**

export const SEVERITY = {
Error: 'Error' as 'Error',
Warning: 'Warning' as 'Warning',
Information: 'Information' as 'Information',
Hint: 'Hint' as 'Hint',
};
Error: 'Error',
Warning: 'Warning',
Information: 'Information',
Hint: 'Hint',
} as const;

@@ -85,11 +85,18 @@ export type Severity = typeof SEVERITY;

} catch (error) {
const range = getRange(error.locations[0], query);
return [
{
severity: DIAGNOSTIC_SEVERITY.Error as DiagnosticSeverity,
message: error.message,
source: 'GraphQL: Syntax',
range,
},
];
if (error instanceof GraphQLError) {
const range = getRange(
error.locations?.[0] ?? { line: 0, column: 0 },
query,
);
return [
{
severity: DIAGNOSTIC_SEVERITY.Error as DiagnosticSeverity,
message: error.message,
source: 'GraphQL: Syntax',
range,
},
];
}
throw error;
}

@@ -96,0 +103,0 @@

@@ -841,3 +841,3 @@ /* eslint-disable jest/expect-expect */

it('parses subscription with inline fragment', () => {
const { t, stream } = getUtils(`
const { t } = getUtils(/* GraphQL */ `
subscription SomeSubscription {

@@ -876,3 +876,3 @@ someSubscription {

it('parses subscription with fragment spread', () => {
const { t, stream } = getUtils(`
const { t } = getUtils(/* GraphQL */ `
subscription SomeSubscription {

@@ -879,0 +879,0 @@ someSubscription {

@@ -190,3 +190,3 @@ /* eslint-disable jest/expect-expect, jest/no-export */

) => {
const { t, stream } = utils;
const { t } = utils;
t.meta('@', { kind: 'Directive' });

@@ -193,0 +193,0 @@ t.meta(name);

@@ -120,3 +120,3 @@ /**

match = this._sourceText.slice(this._pos).match(pattern);
token = match && match[0];
token = match?.[0];
}

@@ -135,2 +135,3 @@

this._start = this._pos;
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- otherwise has type issue
if (token && token.length) {

@@ -137,0 +138,0 @@ this._pos += token.length;

@@ -106,3 +106,3 @@ /**

if (stream.sol()) {
const tabSize = (editorConfig && editorConfig.tabSize) || 2;
const tabSize = editorConfig?.tabSize || 2;
state.indentLevel = Math.floor(stream.indentation() / tabSize);

@@ -175,5 +175,5 @@ }

// Seperator between list elements if necessary.
// Separator between list elements if necessary.
if (state.needsSeperator) {
expected = expected && expected?.separator;
expected = expected?.separator;
}

@@ -194,3 +194,3 @@

// Otherwise, match a Terminal.
if (expected.match && expected.match(token)) {
if (expected.match?.(token)) {
if (expected.update) {

@@ -310,3 +310,3 @@ expected.update(state, token);

// TODO: ParseRules as numerical index
if (state.rule && state.rule[state.step].separator) {
if (state.rule?.[state.step].separator) {
state.needsSeperator = !state.needsSeperator;

@@ -327,2 +327,3 @@ }

(state.rule[state.step] as Rule);
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- otherwise has type issue
return step && step.isList;

@@ -329,0 +330,0 @@ }

@@ -199,3 +199,3 @@ /**

style: 'string',
match: token => token.kind === 'String',
match: (token: Token) => token.kind === 'String',
update(state: State, token: Token) {

@@ -334,3 +334,3 @@ if (token.value.startsWith('"""')) {

update(state: State, token: Token) {
if (state.prevState && state.prevState.prevState) {
if (state.prevState?.prevState) {
state.name = token.value;

@@ -337,0 +337,0 @@ state.prevState.prevState.type = token.value;

@@ -270,27 +270,27 @@ /**

export namespace CompletionItemKind {
export const Text: 1 = 1;
export const Method: 2 = 2;
export const Function: 3 = 3;
export const Constructor: 4 = 4;
export const Field: 5 = 5;
export const Variable: 6 = 6;
export const Class: 7 = 7;
export const Interface: 8 = 8;
export const Module: 9 = 9;
export const Property: 10 = 10;
export const Unit: 11 = 11;
export const Value: 12 = 12;
export const Enum: 13 = 13;
export const Keyword: 14 = 14;
export const Snippet: 15 = 15;
export const Color: 16 = 16;
export const File: 17 = 17;
export const Reference: 18 = 18;
export const Folder: 19 = 19;
export const EnumMember: 20 = 20;
export const Constant: 21 = 21;
export const Struct: 22 = 22;
export const Event: 23 = 23;
export const Operator: 24 = 24;
export const TypeParameter: 25 = 25;
export const Text = 1 as const;
export const Method = 2 as const;
export const Function = 3 as const;
export const Constructor = 4 as const;
export const Field = 5 as const;
export const Variable = 6 as const;
export const Class = 7 as const;
export const Interface = 8 as const;
export const Module = 9 as const;
export const Property = 10 as const;
export const Unit = 11 as const;
export const Value = 12 as const;
export const Enum = 13 as const;
export const Keyword = 14 as const;
export const Snippet = 15 as const;
export const Color = 16 as const;
export const File = 17 as const;
export const Reference = 18 as const;
export const Folder = 19 as const;
export const EnumMember = 20 as const;
export const Constant = 21 as const;
export const Struct = 22 as const;
export const Event = 23 as const;
export const Operator = 24 as const;
export const TypeParameter = 25 as const;
}

@@ -297,0 +297,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc