Socket
Socket
Sign inDemoInstall

graphql-language-service

Package Overview
Dependencies
3
Maintainers
14
Versions
237
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.0-canary-f5992ff0.0 to 6.0.0-canary-298f53ab.0

56

dist/index.js

@@ -1,53 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Range = exports.validateWithCustomRules = exports.collectVariables = exports.Position = exports.pointToOffset = exports.offsetToPosition = exports.getVariablesJSONSchema = exports.getQueryFacts = exports.getOperationFacts = exports.getOperationASTFacts = exports.getFragmentDependenciesForAST = exports.getFragmentDependencies = exports.getASTNodeAtPosition = exports.FileChangeTypeKind = exports.CompletionItemKind = exports.opt = exports.t = exports.list = exports.p = exports.isIgnored = exports.LexRules = exports.RuleKinds = exports.CharacterStream = exports.ParseRules = exports.onlineParser = exports.validateQuery = exports.SuggestionCommand = exports.canUseDirective = exports.DIAGNOSTIC_SEVERITY = exports.SEVERITY = exports.getVariableCompletions = exports.getTypeInfo = exports.getTokenAtPosition = exports.getRange = exports.getOutline = exports.getHoverInformation = exports.getFragmentDefinitions = exports.getFieldDef = exports.getDiagnostics = exports.getDefinitionState = exports.getDefinitionQueryResultForField = exports.getDefinitionQueryResultForNamedType = exports.getDefinitionQueryResultForFragmentSpread = exports.getDefinitionQueryResultForDefinitionNode = exports.getAutocompleteSuggestions = void 0;
var interface_1 = require("./interface");
Object.defineProperty(exports, "getAutocompleteSuggestions", { enumerable: true, get: function () { return interface_1.getAutocompleteSuggestions; } });
Object.defineProperty(exports, "getDefinitionQueryResultForDefinitionNode", { enumerable: true, get: function () { return interface_1.getDefinitionQueryResultForDefinitionNode; } });
Object.defineProperty(exports, "getDefinitionQueryResultForFragmentSpread", { enumerable: true, get: function () { return interface_1.getDefinitionQueryResultForFragmentSpread; } });
Object.defineProperty(exports, "getDefinitionQueryResultForNamedType", { enumerable: true, get: function () { return interface_1.getDefinitionQueryResultForNamedType; } });
Object.defineProperty(exports, "getDefinitionQueryResultForField", { enumerable: true, get: function () { return interface_1.getDefinitionQueryResultForField; } });
Object.defineProperty(exports, "getDefinitionState", { enumerable: true, get: function () { return interface_1.getDefinitionState; } });
Object.defineProperty(exports, "getDiagnostics", { enumerable: true, get: function () { return interface_1.getDiagnostics; } });
Object.defineProperty(exports, "getFieldDef", { enumerable: true, get: function () { return interface_1.getFieldDef; } });
Object.defineProperty(exports, "getFragmentDefinitions", { enumerable: true, get: function () { return interface_1.getFragmentDefinitions; } });
Object.defineProperty(exports, "getHoverInformation", { enumerable: true, get: function () { return interface_1.getHoverInformation; } });
Object.defineProperty(exports, "getOutline", { enumerable: true, get: function () { return interface_1.getOutline; } });
Object.defineProperty(exports, "getRange", { enumerable: true, get: function () { return interface_1.getRange; } });
Object.defineProperty(exports, "getTokenAtPosition", { enumerable: true, get: function () { return interface_1.getTokenAtPosition; } });
Object.defineProperty(exports, "getTypeInfo", { enumerable: true, get: function () { return interface_1.getTypeInfo; } });
Object.defineProperty(exports, "getVariableCompletions", { enumerable: true, get: function () { return interface_1.getVariableCompletions; } });
Object.defineProperty(exports, "SEVERITY", { enumerable: true, get: function () { return interface_1.SEVERITY; } });
Object.defineProperty(exports, "DIAGNOSTIC_SEVERITY", { enumerable: true, get: function () { return interface_1.DIAGNOSTIC_SEVERITY; } });
Object.defineProperty(exports, "canUseDirective", { enumerable: true, get: function () { return interface_1.canUseDirective; } });
Object.defineProperty(exports, "SuggestionCommand", { enumerable: true, get: function () { return interface_1.SuggestionCommand; } });
Object.defineProperty(exports, "validateQuery", { enumerable: true, get: function () { return interface_1.validateQuery; } });
var parser_1 = require("./parser");
Object.defineProperty(exports, "onlineParser", { enumerable: true, get: function () { return parser_1.onlineParser; } });
Object.defineProperty(exports, "ParseRules", { enumerable: true, get: function () { return parser_1.ParseRules; } });
Object.defineProperty(exports, "CharacterStream", { enumerable: true, get: function () { return parser_1.CharacterStream; } });
Object.defineProperty(exports, "RuleKinds", { enumerable: true, get: function () { return parser_1.RuleKinds; } });
Object.defineProperty(exports, "LexRules", { enumerable: true, get: function () { return parser_1.LexRules; } });
Object.defineProperty(exports, "isIgnored", { enumerable: true, get: function () { return parser_1.isIgnored; } });
Object.defineProperty(exports, "p", { enumerable: true, get: function () { return parser_1.p; } });
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return parser_1.list; } });
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return parser_1.t; } });
Object.defineProperty(exports, "opt", { enumerable: true, get: function () { return parser_1.opt; } });
var types_1 = require("./types");
Object.defineProperty(exports, "CompletionItemKind", { enumerable: true, get: function () { return types_1.CompletionItemKind; } });
Object.defineProperty(exports, "FileChangeTypeKind", { enumerable: true, get: function () { return types_1.FileChangeTypeKind; } });
var utils_1 = require("./utils");
Object.defineProperty(exports, "getASTNodeAtPosition", { enumerable: true, get: function () { return utils_1.getASTNodeAtPosition; } });
Object.defineProperty(exports, "getFragmentDependencies", { enumerable: true, get: function () { return utils_1.getFragmentDependencies; } });
Object.defineProperty(exports, "getFragmentDependenciesForAST", { enumerable: true, get: function () { return utils_1.getFragmentDependenciesForAST; } });
Object.defineProperty(exports, "getOperationASTFacts", { enumerable: true, get: function () { return utils_1.getOperationASTFacts; } });
Object.defineProperty(exports, "getOperationFacts", { enumerable: true, get: function () { return utils_1.getOperationFacts; } });
Object.defineProperty(exports, "getQueryFacts", { enumerable: true, get: function () { return utils_1.getQueryFacts; } });
Object.defineProperty(exports, "getVariablesJSONSchema", { enumerable: true, get: function () { return utils_1.getVariablesJSONSchema; } });
Object.defineProperty(exports, "offsetToPosition", { enumerable: true, get: function () { return utils_1.offsetToPosition; } });
Object.defineProperty(exports, "pointToOffset", { enumerable: true, get: function () { return utils_1.pointToOffset; } });
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return utils_1.Position; } });
Object.defineProperty(exports, "collectVariables", { enumerable: true, get: function () { return utils_1.collectVariables; } });
Object.defineProperty(exports, "validateWithCustomRules", { enumerable: true, get: function () { return utils_1.validateWithCustomRules; } });
Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return utils_1.Range; } });
export { getAutocompleteSuggestions, getDefinitionQueryResultForDefinitionNode, getDefinitionQueryResultForFragmentSpread, getDefinitionQueryResultForNamedType, getDefinitionQueryResultForField, getDefinitionState, getDiagnostics, getFieldDef, getFragmentDefinitions, getHoverInformation, getOutline, getRange, getTokenAtPosition, getTypeInfo, getVariableCompletions, SEVERITY, DIAGNOSTIC_SEVERITY, canUseDirective, SuggestionCommand, validateQuery, } from './interface';
export { onlineParser, ParseRules, CharacterStream, RuleKinds, LexRules, isIgnored, p, list, t, opt, } from './parser';
export { CompletionItemKind, FileChangeTypeKind } from './types';
export { getASTNodeAtPosition, getFragmentDependencies, getFragmentDependenciesForAST, getOperationASTFacts, getOperationFacts, getQueryFacts, getVariablesJSONSchema, offsetToPosition, pointToOffset, Position, collectVariables, validateWithCustomRules, Range, } from './utils';
//# sourceMappingURL=index.js.map

33

dist/interface/autocompleteUtils.js

@@ -1,7 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hintList = exports.objectValues = exports.forEachState = exports.getFieldDef = exports.getDefinitionState = void 0;
const graphql_1 = require("graphql");
const introspection_1 = require("graphql/type/introspection");
function getDefinitionState(tokenState) {
import { isCompositeType, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from 'graphql';
export function getDefinitionState(tokenState) {
let definitionState;

@@ -21,12 +17,11 @@ forEachState(tokenState, (state) => {

}
exports.getDefinitionState = getDefinitionState;
function getFieldDef(schema, type, fieldName) {
if (fieldName === introspection_1.SchemaMetaFieldDef.name && schema.getQueryType() === type) {
return introspection_1.SchemaMetaFieldDef;
export function getFieldDef(schema, type, fieldName) {
if (fieldName === SchemaMetaFieldDef.name && schema.getQueryType() === type) {
return SchemaMetaFieldDef;
}
if (fieldName === introspection_1.TypeMetaFieldDef.name && schema.getQueryType() === type) {
return introspection_1.TypeMetaFieldDef;
if (fieldName === TypeMetaFieldDef.name && schema.getQueryType() === type) {
return TypeMetaFieldDef;
}
if (fieldName === introspection_1.TypeNameMetaFieldDef.name && (0, graphql_1.isCompositeType)(type)) {
return introspection_1.TypeNameMetaFieldDef;
if (fieldName === TypeNameMetaFieldDef.name && isCompositeType(type)) {
return TypeNameMetaFieldDef;
}

@@ -38,4 +33,3 @@ if ('getFields' in type) {

}
exports.getFieldDef = getFieldDef;
function forEachState(stack, fn) {
export function forEachState(stack, fn) {
const reverseStateStack = [];

@@ -51,4 +45,3 @@ let state = stack;

}
exports.forEachState = forEachState;
function objectValues(object) {
export function objectValues(object) {
const keys = Object.keys(object);

@@ -62,7 +55,5 @@ const len = keys.length;

}
exports.objectValues = objectValues;
function hintList(token, list) {
export function hintList(token, list) {
return filterAndSortList(list, normalizeText(token.string));
}
exports.hintList = hintList;
function filterAndSortList(list, text) {

@@ -69,0 +60,0 @@ if (!text) {

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLDocumentMode = exports.getTypeInfo = exports.canUseDirective = exports.runOnlineParser = exports.getTokenAtPosition = exports.getFragmentDefinitions = exports.getVariableCompletions = exports.getAutocompleteSuggestions = exports.SuggestionCommand = void 0;
const graphql_1 = require("graphql");
const types_1 = require("../types");
const parser_1 = require("../parser");
const autocompleteUtils_1 = require("./autocompleteUtils");
exports.SuggestionCommand = {
import { isInterfaceType, GraphQLInterfaceType, GraphQLObjectType, Kind, DirectiveLocation, isListType, isNonNullType, isScalarType, isObjectType, isUnionType, isEnumType, isInputObjectType, isOutputType, GraphQLBoolean, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, assertAbstractType, doTypesOverlap, getNamedType, getNullableType, isAbstractType, isCompositeType, isInputType, visit, BREAK, parse, } from 'graphql';
import { CompletionItemKind, InsertTextFormat, } from '../types';
import { CharacterStream, onlineParser, RuleKinds, } from '../parser';
import { forEachState, getDefinitionState, getFieldDef, hintList, objectValues, } from './autocompleteUtils';
export const SuggestionCommand = {
command: 'editor.action.triggerSuggest',

@@ -16,3 +13,3 @@ title: 'Suggestions',

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

@@ -30,18 +27,18 @@ externalFragments.push(def);

const typeSystemKinds = [
graphql_1.Kind.SCHEMA_DEFINITION,
graphql_1.Kind.OPERATION_TYPE_DEFINITION,
graphql_1.Kind.SCALAR_TYPE_DEFINITION,
graphql_1.Kind.OBJECT_TYPE_DEFINITION,
graphql_1.Kind.INTERFACE_TYPE_DEFINITION,
graphql_1.Kind.UNION_TYPE_DEFINITION,
graphql_1.Kind.ENUM_TYPE_DEFINITION,
graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
graphql_1.Kind.DIRECTIVE_DEFINITION,
graphql_1.Kind.SCHEMA_EXTENSION,
graphql_1.Kind.SCALAR_TYPE_EXTENSION,
graphql_1.Kind.OBJECT_TYPE_EXTENSION,
graphql_1.Kind.INTERFACE_TYPE_EXTENSION,
graphql_1.Kind.UNION_TYPE_EXTENSION,
graphql_1.Kind.ENUM_TYPE_EXTENSION,
graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION,
Kind.SCHEMA_DEFINITION,
Kind.OPERATION_TYPE_DEFINITION,
Kind.SCALAR_TYPE_DEFINITION,
Kind.OBJECT_TYPE_DEFINITION,
Kind.INTERFACE_TYPE_DEFINITION,
Kind.UNION_TYPE_DEFINITION,
Kind.ENUM_TYPE_DEFINITION,
Kind.INPUT_OBJECT_TYPE_DEFINITION,
Kind.DIRECTIVE_DEFINITION,
Kind.SCHEMA_EXTENSION,
Kind.SCALAR_TYPE_EXTENSION,
Kind.OBJECT_TYPE_EXTENSION,
Kind.INTERFACE_TYPE_EXTENSION,
Kind.UNION_TYPE_EXTENSION,
Kind.ENUM_TYPE_EXTENSION,
Kind.INPUT_OBJECT_TYPE_EXTENSION,
];

@@ -52,3 +49,3 @@ const hasTypeSystemDefinitions = (sdl) => {

try {
(0, graphql_1.visit)((0, graphql_1.parse)(sdl), {
visit(parse(sdl), {
enter(node) {

@@ -60,3 +57,3 @@ if (node.kind === 'Document') {

hasTypeSystemDef = true;
return graphql_1.BREAK;
return BREAK;
}

@@ -73,3 +70,3 @@ return false;

};
function getAutocompleteSuggestions(schema, queryText, cursor, contextToken, fragmentDefs, options) {
export function getAutocompleteSuggestions(schema, queryText, cursor, contextToken, fragmentDefs, options) {
var _a;

@@ -85,3 +82,3 @@ const opts = Object.assign(Object.assign({}, options), { schema });

const typeInfo = getTypeInfo(schema, token.state);
if (kind === parser_1.RuleKinds.DOCUMENT) {
if (kind === RuleKinds.DOCUMENT) {
if (mode === GraphQLDocumentMode.TYPE_SYSTEM) {

@@ -92,71 +89,71 @@ return getSuggestionsForTypeSystemDefinitions(token);

}
if (kind === parser_1.RuleKinds.EXTEND_DEF) {
if (kind === RuleKinds.EXTEND_DEF) {
return getSuggestionsForExtensionDefinitions(token);
}
if (((_a = prevState === null || prevState === void 0 ? void 0 : prevState.prevState) === null || _a === void 0 ? void 0 : _a.kind) === parser_1.RuleKinds.EXTENSION_DEFINITION &&
if (((_a = prevState === null || prevState === void 0 ? void 0 : prevState.prevState) === null || _a === void 0 ? void 0 : _a.kind) === RuleKinds.EXTENSION_DEFINITION &&
state.name) {
return (0, autocompleteUtils_1.hintList)(token, []);
return hintList(token, []);
}
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === graphql_1.Kind.SCALAR_TYPE_EXTENSION) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(graphql_1.isScalarType)
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === Kind.SCALAR_TYPE_EXTENSION) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(isScalarType)
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === graphql_1.Kind.OBJECT_TYPE_EXTENSION) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(type => (0, graphql_1.isObjectType)(type) && !type.name.startsWith('__'))
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === Kind.OBJECT_TYPE_EXTENSION) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(type => isObjectType(type) && !type.name.startsWith('__'))
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === graphql_1.Kind.INTERFACE_TYPE_EXTENSION) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(graphql_1.isInterfaceType)
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === Kind.INTERFACE_TYPE_EXTENSION) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(isInterfaceType)
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === graphql_1.Kind.UNION_TYPE_EXTENSION) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(graphql_1.isUnionType)
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === Kind.UNION_TYPE_EXTENSION) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(isUnionType)
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === graphql_1.Kind.ENUM_TYPE_EXTENSION) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(type => (0, graphql_1.isEnumType)(type) && !type.name.startsWith('__'))
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === Kind.ENUM_TYPE_EXTENSION) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(type => isEnumType(type) && !type.name.startsWith('__'))
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(graphql_1.isInputObjectType)
if ((prevState === null || prevState === void 0 ? void 0 : prevState.kind) === Kind.INPUT_OBJECT_TYPE_EXTENSION) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(isInputObjectType)
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if (kind === parser_1.RuleKinds.IMPLEMENTS ||
(kind === parser_1.RuleKinds.NAMED_TYPE && (prevState === null || prevState === void 0 ? void 0 : prevState.kind) === parser_1.RuleKinds.IMPLEMENTS)) {
if (kind === RuleKinds.IMPLEMENTS ||
(kind === RuleKinds.NAMED_TYPE && (prevState === null || prevState === void 0 ? void 0 : prevState.kind) === RuleKinds.IMPLEMENTS)) {
return getSuggestionsForImplements(token, state, schema, queryText, typeInfo);
}
if (kind === parser_1.RuleKinds.SELECTION_SET ||
kind === parser_1.RuleKinds.FIELD ||
kind === parser_1.RuleKinds.ALIASED_FIELD) {
if (kind === RuleKinds.SELECTION_SET ||
kind === RuleKinds.FIELD ||
kind === RuleKinds.ALIASED_FIELD) {
return getSuggestionsForFieldNames(token, typeInfo, opts);
}
if (kind === parser_1.RuleKinds.ARGUMENTS ||
(kind === parser_1.RuleKinds.ARGUMENT && step === 0)) {
if (kind === RuleKinds.ARGUMENTS ||
(kind === RuleKinds.ARGUMENT && step === 0)) {
const { argDefs } = typeInfo;
if (argDefs) {
return (0, autocompleteUtils_1.hintList)(token, argDefs.map((argDef) => {
return hintList(token, argDefs.map((argDef) => {
var _a;

@@ -166,6 +163,6 @@ return ({

insertText: argDef.name + ': ',
command: exports.SuggestionCommand,
command: SuggestionCommand,
detail: String(argDef.type),
documentation: (_a = argDef.description) !== null && _a !== void 0 ? _a : undefined,
kind: types_1.CompletionItemKind.Variable,
kind: CompletionItemKind.Variable,
type: argDef.type,

@@ -176,10 +173,10 @@ });

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

@@ -195,20 +192,20 @@ return ({

}
if (kind === parser_1.RuleKinds.ENUM_VALUE ||
(kind === parser_1.RuleKinds.LIST_VALUE && step === 1) ||
(kind === parser_1.RuleKinds.OBJECT_FIELD && step === 2) ||
(kind === parser_1.RuleKinds.ARGUMENT && step === 2)) {
if (kind === RuleKinds.ENUM_VALUE ||
(kind === RuleKinds.LIST_VALUE && step === 1) ||
(kind === RuleKinds.OBJECT_FIELD && step === 2) ||
(kind === RuleKinds.ARGUMENT && step === 2)) {
return getSuggestionsForInputValues(token, typeInfo, queryText, schema);
}
if (kind === parser_1.RuleKinds.VARIABLE && step === 1) {
const namedInputType = (0, graphql_1.getNamedType)(typeInfo.inputType);
if (kind === RuleKinds.VARIABLE && step === 1) {
const namedInputType = getNamedType(typeInfo.inputType);
const variableDefinitions = getVariableCompletions(queryText, schema, token);
return (0, autocompleteUtils_1.hintList)(token, variableDefinitions.filter(v => v.detail === (namedInputType === null || namedInputType === void 0 ? void 0 : namedInputType.name)));
return hintList(token, variableDefinitions.filter(v => v.detail === (namedInputType === null || namedInputType === void 0 ? void 0 : namedInputType.name)));
}
if ((kind === parser_1.RuleKinds.TYPE_CONDITION && step === 1) ||
(kind === parser_1.RuleKinds.NAMED_TYPE &&
if ((kind === RuleKinds.TYPE_CONDITION && step === 1) ||
(kind === RuleKinds.NAMED_TYPE &&
prevState != null &&
prevState.kind === parser_1.RuleKinds.TYPE_CONDITION)) {
prevState.kind === RuleKinds.TYPE_CONDITION)) {
return getSuggestionsForFragmentTypeConditions(token, typeInfo, schema, kind);
}
if (kind === parser_1.RuleKinds.FRAGMENT_SPREAD && step === 1) {
if (kind === RuleKinds.FRAGMENT_SPREAD && step === 1) {
return getSuggestionsForFragmentSpread(token, typeInfo, schema, queryText, Array.isArray(fragmentDefs)

@@ -221,31 +218,31 @@ ? fragmentDefs

!unwrappedState.needsAdvance &&
kind === parser_1.RuleKinds.NAMED_TYPE) ||
kind === parser_1.RuleKinds.LIST_TYPE) {
if (unwrappedState.kind === parser_1.RuleKinds.FIELD_DEF) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(type => (0, graphql_1.isOutputType)(type) && !type.name.startsWith('__'))
kind === RuleKinds.NAMED_TYPE) ||
kind === RuleKinds.LIST_TYPE) {
if (unwrappedState.kind === RuleKinds.FIELD_DEF) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(type => isOutputType(type) && !type.name.startsWith('__'))
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
if (unwrappedState.kind === parser_1.RuleKinds.INPUT_VALUE_DEF) {
return (0, autocompleteUtils_1.hintList)(token, Object.values(schema.getTypeMap())
.filter(type => (0, graphql_1.isInputType)(type) && !type.name.startsWith('__'))
if (unwrappedState.kind === RuleKinds.INPUT_VALUE_DEF) {
return hintList(token, Object.values(schema.getTypeMap())
.filter(type => isInputType(type) && !type.name.startsWith('__'))
.map(type => ({
label: type.name,
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));
}
}
if ((kind === parser_1.RuleKinds.VARIABLE_DEFINITION && step === 2) ||
(kind === parser_1.RuleKinds.LIST_TYPE && step === 1) ||
(kind === parser_1.RuleKinds.NAMED_TYPE &&
if ((kind === RuleKinds.VARIABLE_DEFINITION && step === 2) ||
(kind === RuleKinds.LIST_TYPE && step === 1) ||
(kind === RuleKinds.NAMED_TYPE &&
prevState &&
(prevState.kind === parser_1.RuleKinds.VARIABLE_DEFINITION ||
prevState.kind === parser_1.RuleKinds.LIST_TYPE ||
prevState.kind === parser_1.RuleKinds.NON_NULL_TYPE))) {
(prevState.kind === RuleKinds.VARIABLE_DEFINITION ||
prevState.kind === RuleKinds.LIST_TYPE ||
prevState.kind === RuleKinds.NON_NULL_TYPE))) {
return getSuggestionsForVariableDefinition(token, schema, kind);
}
if (kind === parser_1.RuleKinds.DIRECTIVE) {
if (kind === RuleKinds.DIRECTIVE) {
return getSuggestionsForDirective(token, state, schema, kind);

@@ -255,17 +252,16 @@ }

}
exports.getAutocompleteSuggestions = getAutocompleteSuggestions;
const insertSuffix = ' {\n $1\n}';
const getInsertText = (field) => {
const { type } = field;
if ((0, graphql_1.isCompositeType)(type)) {
if (isCompositeType(type)) {
return insertSuffix;
}
if ((0, graphql_1.isListType)(type) && (0, graphql_1.isCompositeType)(type.ofType)) {
if (isListType(type) && isCompositeType(type.ofType)) {
return insertSuffix;
}
if ((0, graphql_1.isNonNullType)(type)) {
if ((0, graphql_1.isCompositeType)(type.ofType)) {
if (isNonNullType(type)) {
if (isCompositeType(type.ofType)) {
return insertSuffix;
}
if ((0, graphql_1.isListType)(type.ofType) && (0, graphql_1.isCompositeType)(type.ofType.ofType)) {
if (isListType(type.ofType) && isCompositeType(type.ofType.ofType)) {
return insertSuffix;

@@ -277,29 +273,29 @@ }

function getSuggestionsForTypeSystemDefinitions(token) {
return (0, autocompleteUtils_1.hintList)(token, [
{ label: 'extend', kind: types_1.CompletionItemKind.Function },
{ label: 'type', kind: types_1.CompletionItemKind.Function },
{ label: 'interface', kind: types_1.CompletionItemKind.Function },
{ label: 'union', kind: types_1.CompletionItemKind.Function },
{ label: 'input', kind: types_1.CompletionItemKind.Function },
{ label: 'scalar', kind: types_1.CompletionItemKind.Function },
{ label: 'schema', kind: types_1.CompletionItemKind.Function },
return hintList(token, [
{ label: 'extend', kind: CompletionItemKind.Function },
{ label: 'type', kind: CompletionItemKind.Function },
{ label: 'interface', kind: CompletionItemKind.Function },
{ label: 'union', kind: CompletionItemKind.Function },
{ label: 'input', kind: CompletionItemKind.Function },
{ label: 'scalar', kind: CompletionItemKind.Function },
{ label: 'schema', kind: CompletionItemKind.Function },
]);
}
function getSuggestionsForExecutableDefinitions(token) {
return (0, autocompleteUtils_1.hintList)(token, [
{ label: 'query', kind: types_1.CompletionItemKind.Function },
{ label: 'mutation', kind: types_1.CompletionItemKind.Function },
{ label: 'subscription', kind: types_1.CompletionItemKind.Function },
{ label: 'fragment', kind: types_1.CompletionItemKind.Function },
{ label: '{', kind: types_1.CompletionItemKind.Constructor },
return hintList(token, [
{ label: 'query', kind: CompletionItemKind.Function },
{ label: 'mutation', kind: CompletionItemKind.Function },
{ label: 'subscription', kind: CompletionItemKind.Function },
{ label: 'fragment', kind: CompletionItemKind.Function },
{ label: '{', kind: CompletionItemKind.Constructor },
]);
}
function getSuggestionsForExtensionDefinitions(token) {
return (0, autocompleteUtils_1.hintList)(token, [
{ label: 'type', kind: types_1.CompletionItemKind.Function },
{ label: 'interface', kind: types_1.CompletionItemKind.Function },
{ label: 'union', kind: types_1.CompletionItemKind.Function },
{ label: 'input', kind: types_1.CompletionItemKind.Function },
{ label: 'scalar', kind: types_1.CompletionItemKind.Function },
{ label: 'schema', kind: types_1.CompletionItemKind.Function },
return hintList(token, [
{ label: 'type', kind: CompletionItemKind.Function },
{ label: 'interface', kind: CompletionItemKind.Function },
{ label: 'union', kind: CompletionItemKind.Function },
{ label: 'input', kind: CompletionItemKind.Function },
{ label: 'scalar', kind: CompletionItemKind.Function },
{ label: 'schema', kind: CompletionItemKind.Function },
]);

@@ -313,11 +309,11 @@ }

if ('getFields' in parentType) {
fields = (0, autocompleteUtils_1.objectValues)(parentType.getFields());
fields = objectValues(parentType.getFields());
}
if ((0, graphql_1.isCompositeType)(parentType)) {
fields.push(graphql_1.TypeNameMetaFieldDef);
if (isCompositeType(parentType)) {
fields.push(TypeNameMetaFieldDef);
}
if (parentType === ((_a = options === null || options === void 0 ? void 0 : options.schema) === null || _a === void 0 ? void 0 : _a.getQueryType())) {
fields.push(graphql_1.SchemaMetaFieldDef, graphql_1.TypeMetaFieldDef);
fields.push(SchemaMetaFieldDef, TypeMetaFieldDef);
}
return (0, autocompleteUtils_1.hintList)(token, fields.map((field, index) => {
return hintList(token, fields.map((field, index) => {
var _a;

@@ -332,3 +328,3 @@ const suggestion = {

deprecationReason: field.deprecationReason,
kind: types_1.CompletionItemKind.Field,
kind: CompletionItemKind.Field,
type: field.type,

@@ -340,4 +336,4 @@ };

suggestion.insertText = field.name + insertText;
suggestion.insertTextFormat = types_1.InsertTextFormat.Snippet;
suggestion.command = exports.SuggestionCommand;
suggestion.insertTextFormat = InsertTextFormat.Snippet;
suggestion.command = SuggestionCommand;
}

@@ -351,7 +347,7 @@ }

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

@@ -366,3 +362,3 @@ var _a;

deprecationReason: value.deprecationReason,
kind: types_1.CompletionItemKind.EnumMember,
kind: CompletionItemKind.EnumMember,
type: namedInputType,

@@ -373,17 +369,17 @@ });

}
if (namedInputType === graphql_1.GraphQLBoolean) {
return (0, autocompleteUtils_1.hintList)(token, queryVariables.concat([
if (namedInputType === GraphQLBoolean) {
return hintList(token, queryVariables.concat([
{
label: 'true',
detail: String(graphql_1.GraphQLBoolean),
detail: String(GraphQLBoolean),
documentation: 'Not false.',
kind: types_1.CompletionItemKind.Variable,
type: graphql_1.GraphQLBoolean,
kind: CompletionItemKind.Variable,
type: GraphQLBoolean,
},
{
label: 'false',
detail: String(graphql_1.GraphQLBoolean),
detail: String(GraphQLBoolean),
documentation: 'Not true.',
kind: types_1.CompletionItemKind.Variable,
type: graphql_1.GraphQLBoolean,
kind: CompletionItemKind.Variable,
type: GraphQLBoolean,
},

@@ -399,3 +395,3 @@ ]));

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

@@ -406,8 +402,8 @@ const inlineInterfaces = new Set();

if (state.name) {
if (state.kind === parser_1.RuleKinds.INTERFACE_DEF &&
if (state.kind === RuleKinds.INTERFACE_DEF &&
!schemaInterfaceNames.includes(state.name)) {
inlineInterfaces.add(state.name);
}
if (state.kind === parser_1.RuleKinds.NAMED_TYPE &&
((_a = state.prevState) === null || _a === void 0 ? void 0 : _a.kind) === parser_1.RuleKinds.IMPLEMENTS) {
if (state.kind === RuleKinds.NAMED_TYPE &&
((_a = state.prevState) === null || _a === void 0 ? void 0 : _a.kind) === RuleKinds.IMPLEMENTS) {
if (typeInfo.interfaceDef) {

@@ -420,6 +416,6 @@ const existingType = (_b = typeInfo.interfaceDef) === null || _b === void 0 ? void 0 : _b.getInterfaces().find(({ name }) => name === state.name);

const interfaceConfig = (_c = typeInfo.interfaceDef) === null || _c === void 0 ? void 0 : _c.toConfig();
typeInfo.interfaceDef = new graphql_1.GraphQLInterfaceType(Object.assign(Object.assign({}, interfaceConfig), { interfaces: [
typeInfo.interfaceDef = new GraphQLInterfaceType(Object.assign(Object.assign({}, interfaceConfig), { interfaces: [
...interfaceConfig.interfaces,
type ||
new graphql_1.GraphQLInterfaceType({ name: state.name, fields: {} }),
new GraphQLInterfaceType({ name: state.name, fields: {} }),
] }));

@@ -434,6 +430,6 @@ }

const objectTypeConfig = (_e = typeInfo.objectTypeDef) === null || _e === void 0 ? void 0 : _e.toConfig();
typeInfo.objectTypeDef = new graphql_1.GraphQLObjectType(Object.assign(Object.assign({}, objectTypeConfig), { interfaces: [
typeInfo.objectTypeDef = new GraphQLObjectType(Object.assign(Object.assign({}, objectTypeConfig), { interfaces: [
...objectTypeConfig.interfaces,
type ||
new graphql_1.GraphQLInterfaceType({ name: state.name, fields: {} }),
new GraphQLInterfaceType({ name: state.name, fields: {} }),
] }));

@@ -451,6 +447,6 @@ }

!siblingInterfaceNames.includes(name));
return (0, autocompleteUtils_1.hintList)(token, possibleInterfaces.map(type => {
return hintList(token, possibleInterfaces.map(type => {
const result = {
label: type.name,
kind: types_1.CompletionItemKind.Interface,
kind: CompletionItemKind.Interface,
type,

@@ -467,4 +463,4 @@ };

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

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

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

@@ -486,10 +482,10 @@ else {

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

@@ -503,3 +499,3 @@ }));

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

@@ -511,12 +507,12 @@ if (fragmentDefs && fragmentDefs.length > 0) {

!(defState &&
defState.kind === parser_1.RuleKinds.FRAGMENT_DEFINITION &&
defState.kind === RuleKinds.FRAGMENT_DEFINITION &&
defState.name === frag.name.value) &&
(0, graphql_1.isCompositeType)(typeInfo.parentType) &&
(0, graphql_1.isCompositeType)(typeMap[frag.typeCondition.name.value]) &&
(0, graphql_1.doTypesOverlap)(schema, typeInfo.parentType, typeMap[frag.typeCondition.name.value]));
return (0, autocompleteUtils_1.hintList)(token, relevantFrags.map(frag => ({
isCompositeType(typeInfo.parentType) &&
isCompositeType(typeMap[frag.typeCondition.name.value]) &&
doTypesOverlap(schema, typeInfo.parentType, typeMap[frag.typeCondition.name.value]));
return hintList(token, relevantFrags.map(frag => ({
label: frag.name.value,
detail: String(typeMap[frag.typeCondition.name.value]),
documentation: `fragment ${frag.name.value} on ${frag.typeCondition.name.value}`,
kind: types_1.CompletionItemKind.Field,
kind: CompletionItemKind.Field,
type: typeMap[frag.typeCondition.name.value],

@@ -540,3 +536,3 @@ })));

};
function getVariableCompletions(queryText, schema, token) {
export function getVariableCompletions(queryText, schema, token) {
let variableName = null;

@@ -546,7 +542,7 @@ let variableType;

runOnlineParser(queryText, (_, state) => {
if ((state === null || state === void 0 ? void 0 : state.kind) === parser_1.RuleKinds.VARIABLE && state.name) {
if ((state === null || state === void 0 ? void 0 : state.kind) === RuleKinds.VARIABLE && state.name) {
variableName = state.name;
}
if ((state === null || state === void 0 ? void 0 : state.kind) === parser_1.RuleKinds.NAMED_TYPE && variableName) {
const parentDefinition = getParentDefinition(state, parser_1.RuleKinds.TYPE);
if ((state === null || state === void 0 ? void 0 : state.kind) === RuleKinds.NAMED_TYPE && variableName) {
const parentDefinition = getParentDefinition(state, RuleKinds.TYPE);
if (parentDefinition === null || parentDefinition === void 0 ? void 0 : parentDefinition.type) {

@@ -562,3 +558,3 @@ variableType = schema.getType(parentDefinition === null || parentDefinition === void 0 ? void 0 : parentDefinition.type);

type: variableType,
kind: types_1.CompletionItemKind.Variable,
kind: CompletionItemKind.Variable,
};

@@ -569,25 +565,24 @@ variableName = null;

});
return (0, autocompleteUtils_1.objectValues)(definitions);
return objectValues(definitions);
}
exports.getVariableCompletions = getVariableCompletions;
function getFragmentDefinitions(queryText) {
export function getFragmentDefinitions(queryText) {
const fragmentDefs = [];
runOnlineParser(queryText, (_, state) => {
if (state.kind === parser_1.RuleKinds.FRAGMENT_DEFINITION &&
if (state.kind === RuleKinds.FRAGMENT_DEFINITION &&
state.name &&
state.type) {
fragmentDefs.push({
kind: parser_1.RuleKinds.FRAGMENT_DEFINITION,
kind: RuleKinds.FRAGMENT_DEFINITION,
name: {
kind: graphql_1.Kind.NAME,
kind: Kind.NAME,
value: state.name,
},
selectionSet: {
kind: parser_1.RuleKinds.SELECTION_SET,
kind: RuleKinds.SELECTION_SET,
selections: [],
},
typeCondition: {
kind: parser_1.RuleKinds.NAMED_TYPE,
kind: RuleKinds.NAMED_TYPE,
name: {
kind: graphql_1.Kind.NAME,
kind: Kind.NAME,
value: state.type,

@@ -601,10 +596,9 @@ },

}
exports.getFragmentDefinitions = getFragmentDefinitions;
function getSuggestionsForVariableDefinition(token, schema, _kind) {
const inputTypeMap = schema.getTypeMap();
const inputTypes = (0, autocompleteUtils_1.objectValues)(inputTypeMap).filter(graphql_1.isInputType);
return (0, autocompleteUtils_1.hintList)(token, inputTypes.map((type) => ({
const inputTypes = objectValues(inputTypeMap).filter(isInputType);
return hintList(token, inputTypes.map((type) => ({
label: type.name,
documentation: type.description,
kind: types_1.CompletionItemKind.Variable,
kind: CompletionItemKind.Variable,
})));

@@ -618,6 +612,6 @@ }

.filter(directive => canUseDirective(state.prevState, directive));
return (0, autocompleteUtils_1.hintList)(token, directives.map(directive => ({
return hintList(token, directives.map(directive => ({
label: directive.name,
documentation: directive.description || '',
kind: types_1.CompletionItemKind.Function,
kind: CompletionItemKind.Function,
})));

@@ -627,3 +621,3 @@ }

}
function getTokenAtPosition(queryText, cursor, offset = 0) {
export function getTokenAtPosition(queryText, cursor, offset = 0) {
let styleAtCursor = null;

@@ -633,9 +627,10 @@ let stateAtCursor = null;

const token = runOnlineParser(queryText, (stream, state, style, index) => {
if (index === cursor.line &&
stream.getCurrentPosition() + offset >= cursor.character + 1) {
styleAtCursor = style;
stateAtCursor = Object.assign({}, state);
stringAtCursor = stream.current();
return 'BREAK';
if (index !== cursor.line ||
stream.getCurrentPosition() + offset < cursor.character + 1) {
return;
}
styleAtCursor = style;
stateAtCursor = Object.assign({}, state);
stringAtCursor = stream.current();
return 'BREAK';
});

@@ -650,11 +645,10 @@ return {

}
exports.getTokenAtPosition = getTokenAtPosition;
function runOnlineParser(queryText, callback) {
export function runOnlineParser(queryText, callback) {
const lines = queryText.split('\n');
const parser = (0, parser_1.onlineParser)();
const parser = onlineParser();
let state = parser.startState();
let style = '';
let stream = new parser_1.CharacterStream('');
let stream = new CharacterStream('');
for (let i = 0; i < lines.length; i++) {
stream = new parser_1.CharacterStream(lines[i]);
stream = new CharacterStream(lines[i]);
while (!stream.eol()) {

@@ -680,4 +674,3 @@ style = parser.token(stream, state);

}
exports.runOnlineParser = runOnlineParser;
function canUseDirective(state, directive) {
export function canUseDirective(state, directive) {
if (!(state === null || state === void 0 ? void 0 : state.kind)) {

@@ -689,42 +682,42 @@ return false;

switch (kind) {
case parser_1.RuleKinds.QUERY:
return locations.includes(graphql_1.DirectiveLocation.QUERY);
case parser_1.RuleKinds.MUTATION:
return locations.includes(graphql_1.DirectiveLocation.MUTATION);
case parser_1.RuleKinds.SUBSCRIPTION:
return locations.includes(graphql_1.DirectiveLocation.SUBSCRIPTION);
case parser_1.RuleKinds.FIELD:
case parser_1.RuleKinds.ALIASED_FIELD:
return locations.includes(graphql_1.DirectiveLocation.FIELD);
case parser_1.RuleKinds.FRAGMENT_DEFINITION:
return locations.includes(graphql_1.DirectiveLocation.FRAGMENT_DEFINITION);
case parser_1.RuleKinds.FRAGMENT_SPREAD:
return locations.includes(graphql_1.DirectiveLocation.FRAGMENT_SPREAD);
case parser_1.RuleKinds.INLINE_FRAGMENT:
return locations.includes(graphql_1.DirectiveLocation.INLINE_FRAGMENT);
case parser_1.RuleKinds.SCHEMA_DEF:
return locations.includes(graphql_1.DirectiveLocation.SCHEMA);
case parser_1.RuleKinds.SCALAR_DEF:
return locations.includes(graphql_1.DirectiveLocation.SCALAR);
case parser_1.RuleKinds.OBJECT_TYPE_DEF:
return locations.includes(graphql_1.DirectiveLocation.OBJECT);
case parser_1.RuleKinds.FIELD_DEF:
return locations.includes(graphql_1.DirectiveLocation.FIELD_DEFINITION);
case parser_1.RuleKinds.INTERFACE_DEF:
return locations.includes(graphql_1.DirectiveLocation.INTERFACE);
case parser_1.RuleKinds.UNION_DEF:
return locations.includes(graphql_1.DirectiveLocation.UNION);
case parser_1.RuleKinds.ENUM_DEF:
return locations.includes(graphql_1.DirectiveLocation.ENUM);
case parser_1.RuleKinds.ENUM_VALUE:
return locations.includes(graphql_1.DirectiveLocation.ENUM_VALUE);
case parser_1.RuleKinds.INPUT_DEF:
return locations.includes(graphql_1.DirectiveLocation.INPUT_OBJECT);
case parser_1.RuleKinds.INPUT_VALUE_DEF:
case RuleKinds.QUERY:
return locations.includes(DirectiveLocation.QUERY);
case RuleKinds.MUTATION:
return locations.includes(DirectiveLocation.MUTATION);
case RuleKinds.SUBSCRIPTION:
return locations.includes(DirectiveLocation.SUBSCRIPTION);
case RuleKinds.FIELD:
case RuleKinds.ALIASED_FIELD:
return locations.includes(DirectiveLocation.FIELD);
case RuleKinds.FRAGMENT_DEFINITION:
return locations.includes(DirectiveLocation.FRAGMENT_DEFINITION);
case RuleKinds.FRAGMENT_SPREAD:
return locations.includes(DirectiveLocation.FRAGMENT_SPREAD);
case RuleKinds.INLINE_FRAGMENT:
return locations.includes(DirectiveLocation.INLINE_FRAGMENT);
case RuleKinds.SCHEMA_DEF:
return locations.includes(DirectiveLocation.SCHEMA);
case RuleKinds.SCALAR_DEF:
return locations.includes(DirectiveLocation.SCALAR);
case RuleKinds.OBJECT_TYPE_DEF:
return locations.includes(DirectiveLocation.OBJECT);
case RuleKinds.FIELD_DEF:
return locations.includes(DirectiveLocation.FIELD_DEFINITION);
case RuleKinds.INTERFACE_DEF:
return locations.includes(DirectiveLocation.INTERFACE);
case RuleKinds.UNION_DEF:
return locations.includes(DirectiveLocation.UNION);
case RuleKinds.ENUM_DEF:
return locations.includes(DirectiveLocation.ENUM);
case RuleKinds.ENUM_VALUE:
return locations.includes(DirectiveLocation.ENUM_VALUE);
case RuleKinds.INPUT_DEF:
return locations.includes(DirectiveLocation.INPUT_OBJECT);
case RuleKinds.INPUT_VALUE_DEF:
const prevStateKind = prevState === null || prevState === void 0 ? void 0 : prevState.kind;
switch (prevStateKind) {
case parser_1.RuleKinds.ARGUMENTS_DEF:
return locations.includes(graphql_1.DirectiveLocation.ARGUMENT_DEFINITION);
case parser_1.RuleKinds.INPUT_DEF:
return locations.includes(graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION);
case RuleKinds.ARGUMENTS_DEF:
return locations.includes(DirectiveLocation.ARGUMENT_DEFINITION);
case RuleKinds.INPUT_DEF:
return locations.includes(DirectiveLocation.INPUT_FIELD_DEFINITION);
}

@@ -734,4 +727,3 @@ }

}
exports.canUseDirective = canUseDirective;
function getTypeInfo(schema, tokenState) {
export function getTypeInfo(schema, tokenState) {
let argDef;

@@ -748,17 +740,17 @@ let argDefs;

let interfaceDef;
(0, autocompleteUtils_1.forEachState)(tokenState, state => {
forEachState(tokenState, state => {
var _a;
switch (state.kind) {
case parser_1.RuleKinds.QUERY:
case RuleKinds.QUERY:
case 'ShortQuery':
type = schema.getQueryType();
break;
case parser_1.RuleKinds.MUTATION:
case RuleKinds.MUTATION:
type = schema.getMutationType();
break;
case parser_1.RuleKinds.SUBSCRIPTION:
case RuleKinds.SUBSCRIPTION:
type = schema.getSubscriptionType();
break;
case parser_1.RuleKinds.INLINE_FRAGMENT:
case parser_1.RuleKinds.FRAGMENT_DEFINITION:
case RuleKinds.INLINE_FRAGMENT:
case RuleKinds.FRAGMENT_DEFINITION:
if (state.type) {

@@ -768,4 +760,4 @@ type = schema.getType(state.type);

break;
case parser_1.RuleKinds.FIELD:
case parser_1.RuleKinds.ALIASED_FIELD: {
case RuleKinds.FIELD:
case RuleKinds.ALIASED_FIELD: {
if (!type || !state.name) {

@@ -776,3 +768,3 @@ fieldDef = null;

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

@@ -783,12 +775,12 @@ type = fieldDef ? fieldDef.type : null;

}
case parser_1.RuleKinds.SELECTION_SET:
parentType = (0, graphql_1.getNamedType)(type);
case RuleKinds.SELECTION_SET:
parentType = getNamedType(type);
break;
case parser_1.RuleKinds.DIRECTIVE:
case RuleKinds.DIRECTIVE:
directiveDef = state.name ? schema.getDirective(state.name) : null;
break;
case parser_1.RuleKinds.INTERFACE_DEF:
case RuleKinds.INTERFACE_DEF:
if (state.name) {
objectTypeDef = null;
interfaceDef = new graphql_1.GraphQLInterfaceType({
interfaceDef = new GraphQLInterfaceType({
name: state.name,

@@ -800,6 +792,6 @@ interfaces: [],

break;
case parser_1.RuleKinds.OBJECT_TYPE_DEF:
case RuleKinds.OBJECT_TYPE_DEF:
if (state.name) {
interfaceDef = null;
objectTypeDef = new graphql_1.GraphQLObjectType({
objectTypeDef = new GraphQLObjectType({
name: state.name,

@@ -811,13 +803,13 @@ interfaces: [],

break;
case parser_1.RuleKinds.ARGUMENTS: {
case RuleKinds.ARGUMENTS: {
if (state.prevState) {
switch (state.prevState.kind) {
case parser_1.RuleKinds.FIELD:
case RuleKinds.FIELD:
argDefs = fieldDef && fieldDef.args;
break;
case parser_1.RuleKinds.DIRECTIVE:
case RuleKinds.DIRECTIVE:
argDefs =
directiveDef && directiveDef.args;
break;
case parser_1.RuleKinds.ALIASED_FIELD: {
case RuleKinds.ALIASED_FIELD: {
const name = (_a = state.prevState) === null || _a === void 0 ? void 0 : _a.name;

@@ -829,3 +821,3 @@ if (!name) {

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

@@ -849,3 +841,3 @@ if (!field) {

}
case parser_1.RuleKinds.ARGUMENT:
case RuleKinds.ARGUMENT:
if (argDefs) {

@@ -861,6 +853,6 @@ for (let i = 0; i < argDefs.length; i++) {

break;
case parser_1.RuleKinds.ENUM_VALUE:
const enumType = (0, graphql_1.getNamedType)(inputType);
case RuleKinds.ENUM_VALUE:
const enumType = getNamedType(inputType);
enumValue =
enumType instanceof graphql_1.GraphQLEnumType
enumType instanceof GraphQLEnumType
? enumType

@@ -871,19 +863,19 @@ .getValues()

break;
case parser_1.RuleKinds.LIST_VALUE:
const nullableType = (0, graphql_1.getNullableType)(inputType);
case RuleKinds.LIST_VALUE:
const nullableType = getNullableType(inputType);
inputType =
nullableType instanceof graphql_1.GraphQLList ? nullableType.ofType : null;
nullableType instanceof GraphQLList ? nullableType.ofType : null;
break;
case parser_1.RuleKinds.OBJECT_VALUE:
const objectType = (0, graphql_1.getNamedType)(inputType);
case RuleKinds.OBJECT_VALUE:
const objectType = getNamedType(inputType);
objectFieldDefs =
objectType instanceof graphql_1.GraphQLInputObjectType
objectType instanceof GraphQLInputObjectType
? objectType.getFields()
: null;
break;
case parser_1.RuleKinds.OBJECT_FIELD:
case RuleKinds.OBJECT_FIELD:
const objectField = state.name && objectFieldDefs ? objectFieldDefs[state.name] : null;
inputType = objectField === null || objectField === void 0 ? void 0 : objectField.type;
break;
case parser_1.RuleKinds.NAMED_TYPE:
case RuleKinds.NAMED_TYPE:
if (state.name) {

@@ -909,8 +901,7 @@ type = schema.getType(state.name);

}
exports.getTypeInfo = getTypeInfo;
var GraphQLDocumentMode;
export var GraphQLDocumentMode;
(function (GraphQLDocumentMode) {
GraphQLDocumentMode["TYPE_SYSTEM"] = "TYPE_SYSTEM";
GraphQLDocumentMode["EXECUTABLE"] = "EXECUTABLE";
})(GraphQLDocumentMode = exports.GraphQLDocumentMode || (exports.GraphQLDocumentMode = {}));
})(GraphQLDocumentMode || (GraphQLDocumentMode = {}));
function getDocumentMode(documentText, uri) {

@@ -928,6 +919,6 @@ if (uri === null || uri === void 0 ? void 0 : uri.endsWith('.graphqls')) {

[
parser_1.RuleKinds.NAMED_TYPE,
parser_1.RuleKinds.LIST_TYPE,
parser_1.RuleKinds.TYPE,
parser_1.RuleKinds.NON_NULL_TYPE,
RuleKinds.NAMED_TYPE,
RuleKinds.LIST_TYPE,
RuleKinds.TYPE,
RuleKinds.NON_NULL_TYPE,
].includes(state.kind)) {

@@ -934,0 +925,0 @@ return unwrapType(state.prevState);

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

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,6 +10,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefinitionQueryResultForDefinitionNode = exports.getDefinitionQueryResultForFragmentSpread = exports.getDefinitionQueryResultForField = exports.getDefinitionQueryResultForNamedType = exports.LANGUAGE = void 0;
const utils_1 = require("../utils");
exports.LANGUAGE = 'GraphQL';
import { locToRange, offsetToPosition } from '../utils';
export const LANGUAGE = 'GraphQL';
function assert(value, message) {

@@ -24,3 +21,3 @@ if (!value) {

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

@@ -30,5 +27,5 @@ function getPosition(text, node) {

assert(location, 'Expected ASTNode to have a location.');
return (0, utils_1.offsetToPosition)(text, location.start);
return offsetToPosition(text, location.start);
}
function getDefinitionQueryResultForNamedType(text, node, dependencies) {
export function getDefinitionQueryResultForNamedType(text, node, dependencies) {
return __awaiter(this, void 0, void 0, function* () {

@@ -47,4 +44,3 @@ const name = node.name.value;

}
exports.getDefinitionQueryResultForNamedType = getDefinitionQueryResultForNamedType;
function getDefinitionQueryResultForField(fieldName, typeName, dependencies) {
export function getDefinitionQueryResultForField(fieldName, typeName, dependencies) {
var _a;

@@ -70,4 +66,3 @@ return __awaiter(this, void 0, void 0, function* () {

}
exports.getDefinitionQueryResultForField = getDefinitionQueryResultForField;
function getDefinitionQueryResultForFragmentSpread(text, fragment, dependencies) {
export function getDefinitionQueryResultForFragmentSpread(text, fragment, dependencies) {
return __awaiter(this, void 0, void 0, function* () {

@@ -86,4 +81,3 @@ const name = fragment.name.value;

}
exports.getDefinitionQueryResultForFragmentSpread = getDefinitionQueryResultForFragmentSpread;
function getDefinitionQueryResultForDefinitionNode(path, text, definition) {
export function getDefinitionQueryResultForDefinitionNode(path, text, definition) {
return {

@@ -94,3 +88,2 @@ definitions: [getDefinitionForFragmentDefinition(path, text, definition)],

}
exports.getDefinitionQueryResultForDefinitionNode = getDefinitionQueryResultForDefinitionNode;
function getDefinitionForFragmentDefinition(path, text, definition) {

@@ -106,3 +99,3 @@ const { name } = definition;

name: name.value || '',
language: exports.LANGUAGE,
language: LANGUAGE,
projectRoot: path,

@@ -119,3 +112,3 @@ };

name: name.value || '',
language: exports.LANGUAGE,
language: LANGUAGE,
projectRoot: path,

@@ -132,3 +125,3 @@ };

name: name.value || '',
language: exports.LANGUAGE,
language: LANGUAGE,
projectRoot: path,

@@ -135,0 +128,0 @@ };

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRange = exports.validateQuery = exports.getDiagnostics = exports.DIAGNOSTIC_SEVERITY = exports.SEVERITY = void 0;
const graphql_1 = require("graphql");
const parser_1 = require("../parser");
const utils_1 = require("../utils");
exports.SEVERITY = {
import { GraphQLError, print, validate, NoDeprecatedCustomRule, parse, } from 'graphql';
import { CharacterStream, onlineParser } from '../parser';
import { Range, validateWithCustomRules, Position } from '../utils';
export const SEVERITY = {
Error: 'Error',

@@ -13,7 +10,7 @@ Warning: 'Warning',

};
exports.DIAGNOSTIC_SEVERITY = {
[exports.SEVERITY.Error]: 1,
[exports.SEVERITY.Warning]: 2,
[exports.SEVERITY.Information]: 3,
[exports.SEVERITY.Hint]: 4,
export const DIAGNOSTIC_SEVERITY = {
[SEVERITY.Error]: 1,
[SEVERITY.Warning]: 2,
[SEVERITY.Information]: 3,
[SEVERITY.Hint]: 4,
};

@@ -25,3 +22,3 @@ const invariant = (condition, message) => {

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

@@ -34,14 +31,14 @@ let ast = null;

? externalFragments
: externalFragments.reduce((acc, node) => acc + (0, graphql_1.print)(node) + '\n\n', '');
: externalFragments.reduce((acc, node) => acc + print(node) + '\n\n', '');
}
const enhancedQuery = fragments ? `${query}\n\n${fragments}` : query;
try {
ast = (0, graphql_1.parse)(enhancedQuery);
ast = parse(enhancedQuery);
}
catch (error) {
if (error instanceof graphql_1.GraphQLError) {
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 }, enhancedQuery);
return [
{
severity: exports.DIAGNOSTIC_SEVERITY.Error,
severity: DIAGNOSTIC_SEVERITY.Error,
message: error.message,

@@ -57,14 +54,12 @@ source: 'GraphQL: Syntax',

}
exports.getDiagnostics = getDiagnostics;
function validateQuery(ast, schema = null, customRules, isRelayCompatMode) {
export function validateQuery(ast, schema = null, customRules, isRelayCompatMode) {
if (!schema) {
return [];
}
const validationErrorAnnotations = (0, utils_1.validateWithCustomRules)(schema, ast, customRules, isRelayCompatMode).flatMap(error => annotations(error, exports.DIAGNOSTIC_SEVERITY.Error, 'Validation'));
const deprecationWarningAnnotations = (0, graphql_1.validate)(schema, ast, [
graphql_1.NoDeprecatedCustomRule,
]).flatMap(error => annotations(error, exports.DIAGNOSTIC_SEVERITY.Warning, 'Deprecation'));
const validationErrorAnnotations = validateWithCustomRules(schema, ast, customRules, isRelayCompatMode).flatMap(error => annotations(error, DIAGNOSTIC_SEVERITY.Error, 'Validation'));
const deprecationWarningAnnotations = validate(schema, ast, [
NoDeprecatedCustomRule,
]).flatMap(error => annotations(error, DIAGNOSTIC_SEVERITY.Warning, 'Deprecation'));
return validationErrorAnnotations.concat(deprecationWarningAnnotations);
}
exports.validateQuery = validateQuery;
function annotations(error, severity, type) {

@@ -90,3 +85,3 @@ if (!error.nodes) {

severity,
range: new utils_1.Range(new utils_1.Position(loc.line - 1, loc.column - 1), new utils_1.Position(loc.line - 1, end)),
range: new Range(new Position(loc.line - 1, loc.column - 1), new Position(loc.line - 1, end)),
});

@@ -97,4 +92,4 @@ }

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

@@ -105,3 +100,3 @@ const lines = queryText.split('\n');

for (let i = 0; i < location.line; i++) {
stream = new parser_1.CharacterStream(lines[i]);
stream = new CharacterStream(lines[i]);
while (!stream.eol()) {

@@ -118,5 +113,4 @@ const style = parser.token(stream, state);

const end = stream.getCurrentPosition();
return new utils_1.Range(new utils_1.Position(line, start), new utils_1.Position(line, end));
return new Range(new Position(line, start), new Position(line, end));
}
exports.getRange = getRange;
function getLocation(node) {

@@ -123,0 +117,0 @@ const typeCastedNode = node;

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHoverInformation = void 0;
const graphql_1 = require("graphql");
const getAutocompleteSuggestions_1 = require("./getAutocompleteSuggestions");
function getHoverInformation(schema, queryText, cursor, contextToken, config) {
const token = contextToken || (0, getAutocompleteSuggestions_1.getTokenAtPosition)(queryText, cursor);
import { GraphQLNonNull, GraphQLList, } from 'graphql';
import { getTokenAtPosition, getTypeInfo } from './getAutocompleteSuggestions';
export function getHoverInformation(schema, queryText, cursor, contextToken, config) {
const token = contextToken || getTokenAtPosition(queryText, cursor);
if (!schema || !token || !token.state) {

@@ -12,3 +9,3 @@ return '';

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

@@ -60,3 +57,2 @@ if ((kind === 'Field' && step === 0 && typeInfo.fieldDef) ||

}
exports.getHoverInformation = getHoverInformation;
function renderMdCodeStart(into, options) {

@@ -127,7 +123,7 @@ if (options.useMarkdown) {

}
if (t instanceof graphql_1.GraphQLNonNull) {
if (t instanceof GraphQLNonNull) {
renderType(into, typeInfo, options, t.ofType);
text(into, '!');
}
else if (t instanceof graphql_1.GraphQLList) {
else if (t instanceof GraphQLList) {
text(into, '[');

@@ -134,0 +130,0 @@ renderType(into, typeInfo, options, t.ofType);

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOutline = void 0;
const graphql_1 = require("graphql");
const utils_1 = require("../utils");
const { INLINE_FRAGMENT } = graphql_1.Kind;
import { Kind, parse, visit, } from 'graphql';
import { offsetToPosition } from '../utils';
const { INLINE_FRAGMENT } = Kind;
const OUTLINEABLE_KINDS = {

@@ -24,6 +21,6 @@ Field: true,

};
function getOutline(documentText) {
export function getOutline(documentText) {
let ast;
try {
ast = (0, graphql_1.parse)(documentText);
ast = parse(documentText);
}

@@ -34,3 +31,3 @@ catch (_a) {

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

@@ -45,3 +42,2 @@ if (visitorFns !== undefined && node.kind in visitorFns) {

}
exports.getOutline = getOutline;
function outlineTreeConverter(docText) {

@@ -51,4 +47,4 @@ const meta = (node) => {

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

@@ -59,3 +55,3 @@ children: node.selectionSet || node.fields || node.values || node.arguments || [],

return {
Field: (node) => {
Field(node) {
const tokenizedText = node.alias

@@ -107,6 +103,6 @@ ? [buildToken('plain', node.alias), buildToken('plain', ': ')]

] }, meta(node))),
InputValueDefinition: (node) => {
InputValueDefinition(node) {
return Object.assign({ tokenizedText: [buildToken('plain', node.name)] }, meta(node));
},
FieldDefinition: (node) => {
FieldDefinition(node) {
return Object.assign({ tokenizedText: [buildToken('plain', node.name)] }, meta(node));

@@ -113,0 +109,0 @@ },

@@ -1,26 +0,7 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = 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) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHoverInformation = exports.getOutline = void 0;
__exportStar(require("./autocompleteUtils"), exports);
__exportStar(require("./getAutocompleteSuggestions"), exports);
__exportStar(require("./getDefinition"), exports);
__exportStar(require("./getDiagnostics"), exports);
var getOutline_1 = require("./getOutline");
Object.defineProperty(exports, "getOutline", { enumerable: true, get: function () { return getOutline_1.getOutline; } });
var getHoverInformation_1 = require("./getHoverInformation");
Object.defineProperty(exports, "getHoverInformation", { enumerable: true, get: function () { return getHoverInformation_1.getHoverInformation; } });
export * from './autocompleteUtils';
export * from './getAutocompleteSuggestions';
export * from './getDefinition';
export * from './getDiagnostics';
export { getOutline } from './getOutline';
export { getHoverInformation } from './getHoverInformation';
//# sourceMappingURL=index.js.map

@@ -1,5 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class CharacterStream {
export default class CharacterStream {
constructor(sourceText) {
this._start = 0;
this._pos = 0;
this.getStartOfToken = () => this._start;

@@ -96,4 +96,2 @@ this.getCurrentPosition = () => this._pos;

this.current = () => this._sourceText.slice(this._start, this._pos);
this._start = 0;
this._pos = 0;
this._sourceText = sourceText;

@@ -116,3 +114,2 @@ }

}
exports.default = CharacterStream;
//# sourceMappingURL=CharacterStream.js.map

@@ -1,36 +0,6 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = 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) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.onlineParser = exports.t = exports.p = exports.opt = exports.list = exports.butNot = exports.isIgnored = exports.ParseRules = exports.LexRules = exports.CharacterStream = void 0;
var CharacterStream_1 = require("./CharacterStream");
Object.defineProperty(exports, "CharacterStream", { enumerable: true, get: function () { return __importDefault(CharacterStream_1).default; } });
var Rules_1 = require("./Rules");
Object.defineProperty(exports, "LexRules", { enumerable: true, get: function () { return Rules_1.LexRules; } });
Object.defineProperty(exports, "ParseRules", { enumerable: true, get: function () { return Rules_1.ParseRules; } });
Object.defineProperty(exports, "isIgnored", { enumerable: true, get: function () { return Rules_1.isIgnored; } });
var RuleHelpers_1 = require("./RuleHelpers");
Object.defineProperty(exports, "butNot", { enumerable: true, get: function () { return RuleHelpers_1.butNot; } });
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return RuleHelpers_1.list; } });
Object.defineProperty(exports, "opt", { enumerable: true, get: function () { return RuleHelpers_1.opt; } });
Object.defineProperty(exports, "p", { enumerable: true, get: function () { return RuleHelpers_1.p; } });
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return RuleHelpers_1.t; } });
var onlineParser_1 = require("./onlineParser");
Object.defineProperty(exports, "onlineParser", { enumerable: true, get: function () { return __importDefault(onlineParser_1).default; } });
__exportStar(require("./types"), exports);
export { default as CharacterStream } from './CharacterStream';
export { LexRules, ParseRules, isIgnored } from './Rules';
export { butNot, list, opt, p, t } from './RuleHelpers';
export { default as onlineParser } from './onlineParser';
export * from './types';
//# sourceMappingURL=index.js.map

@@ -1,9 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Rules_1 = require("./Rules");
const graphql_1 = require("graphql");
function onlineParser(options = {
eatWhitespace: stream => stream.eatWhile(Rules_1.isIgnored),
lexRules: Rules_1.LexRules,
parseRules: Rules_1.ParseRules,
import { LexRules, ParseRules, isIgnored } from './Rules';
import { Kind } from 'graphql';
export default function onlineParser(options = {
eatWhitespace: stream => stream.eatWhile(isIgnored),
lexRules: LexRules,
parseRules: ParseRules,
editorConfig: {},

@@ -23,3 +21,3 @@ }) {

};
pushRule(options.parseRules, initialState, graphql_1.Kind.DOCUMENT);
pushRule(options.parseRules, initialState, Kind.DOCUMENT);
return initialState;

@@ -32,3 +30,2 @@ },

}
exports.default = onlineParser;
function getToken(stream, state, options) {

@@ -35,0 +32,0 @@ var _a;

@@ -1,13 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.p = exports.t = exports.butNot = exports.list = exports.opt = void 0;
function opt(ofRule) {
export function opt(ofRule) {
return { ofRule };
}
exports.opt = opt;
function list(ofRule, separator) {
export function list(ofRule, separator) {
return { ofRule, isList: true, separator };
}
exports.list = list;
function butNot(rule, exclusions) {
export function butNot(rule, exclusions) {
const ruleMatch = rule.match;

@@ -24,8 +19,6 @@ rule.match = token => {

}
exports.butNot = butNot;
function t(kind, style) {
export function t(kind, style) {
return { style, match: (token) => token.kind === kind };
}
exports.t = t;
function p(value, style) {
export function p(value, style) {
return {

@@ -36,3 +29,2 @@ style: style || 'punctuation',

}
exports.p = p;
//# sourceMappingURL=RuleHelpers.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParseRules = exports.LexRules = exports.isIgnored = void 0;
const RuleHelpers_1 = require("./RuleHelpers");
const graphql_1 = require("graphql");
const isIgnored = (ch) => ch === ' ' ||
import { opt, list, butNot, t, p } from './RuleHelpers';
import { Kind } from 'graphql';
export const isIgnored = (ch) => ch === ' ' ||
ch === '\t' ||

@@ -13,4 +10,3 @@ ch === ',' ||

ch === '\u00A0';
exports.isIgnored = isIgnored;
exports.LexRules = {
export const LexRules = {
Name: /^[_A-Za-z][_0-9A-Za-z]*/,

@@ -22,4 +18,4 @@ Punctuation: /^(?:!|\$|\(|\)|\.\.\.|:|=|&|@|\[|]|\{|\||\})/,

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

@@ -36,3 +32,3 @@ switch (token.value) {

case 'fragment':
return graphql_1.Kind.FRAGMENT_DEFINITION;
return Kind.FRAGMENT_DEFINITION;
case 'schema':

@@ -61,5 +57,5 @@ return 'SchemaDef';

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

@@ -69,5 +65,5 @@ ],

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

@@ -77,12 +73,12 @@ ],

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

@@ -99,21 +95,21 @@ return token.value === '...'

name('property'),
(0, RuleHelpers_1.p)(':'),
p(':'),
name('qualifier'),
(0, RuleHelpers_1.opt)('Arguments'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.opt)('SelectionSet'),
opt('Arguments'),
list('Directive'),
opt('SelectionSet'),
],
Field: [
name('property'),
(0, RuleHelpers_1.opt)('Arguments'),
(0, RuleHelpers_1.list)('Directive'),
(0, RuleHelpers_1.opt)('SelectionSet'),
opt('Arguments'),
list('Directive'),
opt('SelectionSet'),
],
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')],
Arguments: [p('('), list('Argument'), p(')')],
Argument: [name('attribute'), p(':'), 'Value'],
FragmentSpread: [p('...'), name('def'), list('Directive')],
InlineFragment: [
(0, RuleHelpers_1.p)('...'),
(0, RuleHelpers_1.opt)('TypeCondition'),
(0, RuleHelpers_1.list)('Directive'),
p('...'),
opt('TypeCondition'),
list('Directive'),
'SelectionSet',

@@ -123,5 +119,5 @@ ],

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

@@ -160,3 +156,3 @@ ],

},
NumberValue: [(0, RuleHelpers_1.t)('Number', 'number')],
NumberValue: [t('Number', 'number')],
StringValue: [

@@ -173,22 +169,22 @@ {

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

@@ -198,42 +194,42 @@ InterfaceDef: [

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

@@ -243,5 +239,5 @@ UnionDef: [

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

@@ -252,15 +248,15 @@ UnionMember: ['NamedType'],

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

@@ -271,24 +267,24 @@ ExtendDef: [word('extend'), 'ExtensionDefinition'],

case 'schema':
return graphql_1.Kind.SCHEMA_EXTENSION;
return Kind.SCHEMA_EXTENSION;
case 'scalar':
return graphql_1.Kind.SCALAR_TYPE_EXTENSION;
return Kind.SCALAR_TYPE_EXTENSION;
case 'type':
return graphql_1.Kind.OBJECT_TYPE_EXTENSION;
return Kind.OBJECT_TYPE_EXTENSION;
case 'interface':
return graphql_1.Kind.INTERFACE_TYPE_EXTENSION;
return Kind.INTERFACE_TYPE_EXTENSION;
case 'union':
return graphql_1.Kind.UNION_TYPE_EXTENSION;
return Kind.UNION_TYPE_EXTENSION;
case 'enum':
return graphql_1.Kind.ENUM_TYPE_EXTENSION;
return Kind.ENUM_TYPE_EXTENSION;
case 'input':
return graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION;
return Kind.INPUT_OBJECT_TYPE_EXTENSION;
}
},
[graphql_1.Kind.SCHEMA_EXTENSION]: ['SchemaDef'],
[graphql_1.Kind.SCALAR_TYPE_EXTENSION]: ['ScalarDef'],
[graphql_1.Kind.OBJECT_TYPE_EXTENSION]: ['ObjectTypeDef'],
[graphql_1.Kind.INTERFACE_TYPE_EXTENSION]: ['InterfaceDef'],
[graphql_1.Kind.UNION_TYPE_EXTENSION]: ['UnionDef'],
[graphql_1.Kind.ENUM_TYPE_EXTENSION]: ['EnumDef'],
[graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION]: ['InputDef'],
[Kind.SCHEMA_EXTENSION]: ['SchemaDef'],
[Kind.SCALAR_TYPE_EXTENSION]: ['ScalarDef'],
[Kind.OBJECT_TYPE_EXTENSION]: ['ObjectTypeDef'],
[Kind.INTERFACE_TYPE_EXTENSION]: ['InterfaceDef'],
[Kind.UNION_TYPE_EXTENSION]: ['UnionDef'],
[Kind.ENUM_TYPE_EXTENSION]: ['EnumDef'],
[Kind.INPUT_OBJECT_TYPE_EXTENSION]: ['InputDef'],
};

@@ -295,0 +291,0 @@ function word(value) {

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleKinds = exports.AdditionalRuleKinds = void 0;
const graphql_1 = require("graphql");
exports.AdditionalRuleKinds = {
import { Kind } from 'graphql';
export const AdditionalRuleKinds = {
ALIASED_FIELD: 'AliasedField',

@@ -35,3 +32,3 @@ ARGUMENTS: 'Arguments',

};
exports.RuleKinds = Object.assign(Object.assign({}, graphql_1.Kind), exports.AdditionalRuleKinds);
export const RuleKinds = Object.assign(Object.assign({}, Kind), AdditionalRuleKinds);
//# sourceMappingURL=types.js.map
import type { Diagnostic as DiagnosticType, CompletionItem as CompletionItemType } from 'vscode-languageserver-types';
export { InsertTextFormat } from 'vscode-languageserver-types';
import type { ASTNode, GraphQLSchema } from 'graphql';
import type { DocumentNode, FragmentDefinitionNode, NamedTypeNode, TypeDefinitionNode, NameNode } from 'graphql/language';
import type { GraphQLArgument, GraphQLEnumValue, GraphQLField, GraphQLInputFieldMap, GraphQLInterfaceType, GraphQLObjectType, GraphQLType } from 'graphql/type/definition';
import type { GraphQLDirective } from 'graphql/type/directives';
import type { ASTNode, GraphQLSchema, DocumentNode, FragmentDefinitionNode, NamedTypeNode, TypeDefinitionNode, NameNode, GraphQLArgument, GraphQLEnumValue, GraphQLField, GraphQLInputFieldMap, GraphQLInterfaceType, GraphQLObjectType, GraphQLType, GraphQLDirective } from 'graphql';
export declare type Maybe<T> = T | null | undefined;

@@ -8,0 +5,0 @@ import type { GraphQLConfig, GraphQLProjectConfig, GraphQLExtensionDeclaration } from 'graphql-config';

@@ -1,7 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompletionItemKind = exports.FileChangeTypeKind = exports.InsertTextFormat = void 0;
var vscode_languageserver_types_1 = require("vscode-languageserver-types");
Object.defineProperty(exports, "InsertTextFormat", { enumerable: true, get: function () { return vscode_languageserver_types_1.InsertTextFormat; } });
exports.FileChangeTypeKind = {
export { InsertTextFormat } from 'vscode-languageserver-types';
export const FileChangeTypeKind = {
Created: 1,

@@ -11,3 +7,3 @@ Changed: 2,

};
var CompletionItemKind;
export var CompletionItemKind;
(function (CompletionItemKind) {

@@ -39,3 +35,3 @@ CompletionItemKind.Text = 1;

CompletionItemKind.TypeParameter = 25;
})(CompletionItemKind = exports.CompletionItemKind || (exports.CompletionItemKind = {}));
})(CompletionItemKind || (CompletionItemKind = {}));
//# sourceMappingURL=types.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.collectVariables = void 0;
const graphql_1 = require("graphql");
function collectVariables(schema, documentAST) {
import { typeFromAST, GraphQLFloat, Kind, } from 'graphql';
export function collectVariables(schema, documentAST) {
const variableToType = Object.create(null);

@@ -12,9 +9,9 @@ for (const definition of documentAST.definitions) {

for (const { variable, type } of variableDefinitions) {
const inputType = (0, graphql_1.typeFromAST)(schema, type);
const inputType = typeFromAST(schema, type);
if (inputType) {
variableToType[variable.name.value] = inputType;
}
else if (type.kind === graphql_1.Kind.NAMED_TYPE &&
else if (type.kind === Kind.NAMED_TYPE &&
type.name.value === 'Float') {
variableToType[variable.name.value] = graphql_1.GraphQLFloat;
variableToType[variable.name.value] = GraphQLFloat;
}

@@ -27,3 +24,2 @@ }

}
exports.collectVariables = collectVariables;
//# sourceMappingURL=collectVariables.js.map

@@ -1,10 +0,4 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFragmentDependenciesForAST = exports.getFragmentDependencies = void 0;
const graphql_1 = require("graphql");
const nullthrows_1 = __importDefault(require("nullthrows"));
const getFragmentDependencies = (operationString, fragmentDefinitions) => {
import { parse, visit } from 'graphql';
import nullthrows from 'nullthrows';
export const getFragmentDependencies = (operationString, fragmentDefinitions) => {
if (!fragmentDefinitions) {

@@ -15,3 +9,3 @@ return [];

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

@@ -21,6 +15,5 @@ catch (_a) {

}
return (0, exports.getFragmentDependenciesForAST)(parsedOperation, fragmentDefinitions);
return getFragmentDependenciesForAST(parsedOperation, fragmentDefinitions);
};
exports.getFragmentDependencies = getFragmentDependencies;
const getFragmentDependenciesForAST = (parsedOperation, fragmentDefinitions) => {
export const getFragmentDependenciesForAST = (parsedOperation, fragmentDefinitions) => {
if (!fragmentDefinitions) {

@@ -31,3 +24,3 @@ return [];

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

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

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

@@ -51,7 +44,7 @@ }

for (const ast of asts) {
(0, graphql_1.visit)(ast, {
visit(ast, {
FragmentSpread(node) {
if (!referencedFragNames.has(node.name.value) &&
fragmentDefinitions.get(node.name.value)) {
asts.add((0, nullthrows_1.default)(fragmentDefinitions.get(node.name.value)));
asts.add(nullthrows(fragmentDefinitions.get(node.name.value)));
referencedFragNames.add(node.name.value);

@@ -67,3 +60,2 @@ }

};
exports.getFragmentDependenciesForAST = getFragmentDependenciesForAST;
//# sourceMappingURL=fragmentDependencies.js.map

@@ -1,5 +0,5 @@

import { ASTNode } from 'graphql/language';
import { IPosition as TPosition } from '../types';
import { ASTNode } from 'graphql';
export declare function getASTNodeAtPosition(query: string, ast: ASTNode, point: TPosition): ASTNode | undefined;
export declare function pointToOffset(text: string, point: TPosition): number;
//# sourceMappingURL=getASTNodeAtPosition.d.ts.map

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pointToOffset = exports.getASTNodeAtPosition = void 0;
const graphql_1 = require("graphql");
function getASTNodeAtPosition(query, ast, point) {
import { visit } from 'graphql';
export function getASTNodeAtPosition(query, ast, point) {
const offset = pointToOffset(query, point);
let nodeContainingPosition;
(0, graphql_1.visit)(ast, {
visit(ast, {
enter(node) {

@@ -28,4 +25,3 @@ if (node.kind !== 'Name' &&

}
exports.getASTNodeAtPosition = getASTNodeAtPosition;
function pointToOffset(text, point) {
export function pointToOffset(text, point) {
const linesUntilPosition = text.split('\n').slice(0, point.line);

@@ -37,3 +33,2 @@ return (point.character +

}
exports.pointToOffset = pointToOffset;
//# sourceMappingURL=getASTNodeAtPosition.js.map

@@ -1,12 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getQueryFacts = exports.getOperationASTFacts = void 0;
const graphql_1 = require("graphql");
const collectVariables_1 = require("./collectVariables");
function getOperationASTFacts(documentAST, schema) {
import { parse, visit } from 'graphql';
import { collectVariables } from './collectVariables';
export function getOperationASTFacts(documentAST, schema) {
const variableToType = schema
? (0, collectVariables_1.collectVariables)(schema, documentAST)
? collectVariables(schema, documentAST)
: undefined;
const operations = [];
(0, graphql_1.visit)(documentAST, {
visit(documentAST, {
OperationDefinition(node) {

@@ -18,4 +15,3 @@ operations.push(node);

}
exports.getOperationASTFacts = getOperationASTFacts;
function getOperationFacts(schema, documentString) {
export default function getOperationFacts(schema, documentString) {
if (!documentString) {

@@ -25,3 +21,3 @@ return;

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

@@ -33,4 +29,3 @@ }

}
exports.default = getOperationFacts;
exports.getQueryFacts = getOperationFacts;
export const getQueryFacts = getOperationFacts;
//# sourceMappingURL=getOperationFacts.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVariablesJSONSchema = exports.defaultJSONSchemaOptions = void 0;
const graphql_1 = require("graphql");
exports.defaultJSONSchemaOptions = {
import { isEnumType, isInputObjectType, isListType, isNonNullType, isScalarType, } from 'graphql';
export const defaultJSONSchemaOptions = {
useMarkdownDescription: false,

@@ -12,7 +9,7 @@ };

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

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

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

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

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

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

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

@@ -150,3 +147,3 @@ if (options === null || options === void 0 ? void 0 : options.definitionMarker.mark(type.name)) {

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

@@ -168,3 +165,3 @@ !definition.description) {

}
function getVariablesJSONSchema(variableToType, options) {
export function getVariablesJSONSchema(variableToType, options) {
var _a;

@@ -192,3 +189,2 @@ const jsonSchema = {

}
exports.getVariablesJSONSchema = getVariablesJSONSchema;
//# sourceMappingURL=getVariablesJSONSchema.js.map

@@ -1,28 +0,8 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getQueryFacts = exports.getOperationASTFacts = exports.getOperationFacts = exports.collectVariables = exports.validateWithCustomRules = exports.offsetToPosition = exports.locToRange = exports.Range = exports.Position = exports.pointToOffset = exports.getASTNodeAtPosition = exports.getVariablesJSONSchema = exports.getFragmentDependenciesForAST = exports.getFragmentDependencies = void 0;
var fragmentDependencies_1 = require("./fragmentDependencies");
Object.defineProperty(exports, "getFragmentDependencies", { enumerable: true, get: function () { return fragmentDependencies_1.getFragmentDependencies; } });
Object.defineProperty(exports, "getFragmentDependenciesForAST", { enumerable: true, get: function () { return fragmentDependencies_1.getFragmentDependenciesForAST; } });
var getVariablesJSONSchema_1 = require("./getVariablesJSONSchema");
Object.defineProperty(exports, "getVariablesJSONSchema", { enumerable: true, get: function () { return getVariablesJSONSchema_1.getVariablesJSONSchema; } });
var getASTNodeAtPosition_1 = require("./getASTNodeAtPosition");
Object.defineProperty(exports, "getASTNodeAtPosition", { enumerable: true, get: function () { return getASTNodeAtPosition_1.getASTNodeAtPosition; } });
Object.defineProperty(exports, "pointToOffset", { enumerable: true, get: function () { return getASTNodeAtPosition_1.pointToOffset; } });
var Range_1 = require("./Range");
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return Range_1.Position; } });
Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return Range_1.Range; } });
Object.defineProperty(exports, "locToRange", { enumerable: true, get: function () { return Range_1.locToRange; } });
Object.defineProperty(exports, "offsetToPosition", { enumerable: true, get: function () { return Range_1.offsetToPosition; } });
var validateWithCustomRules_1 = require("./validateWithCustomRules");
Object.defineProperty(exports, "validateWithCustomRules", { enumerable: true, get: function () { return validateWithCustomRules_1.validateWithCustomRules; } });
var collectVariables_1 = require("./collectVariables");
Object.defineProperty(exports, "collectVariables", { enumerable: true, get: function () { return collectVariables_1.collectVariables; } });
var getOperationFacts_1 = require("./getOperationFacts");
Object.defineProperty(exports, "getOperationFacts", { enumerable: true, get: function () { return __importDefault(getOperationFacts_1).default; } });
Object.defineProperty(exports, "getOperationASTFacts", { enumerable: true, get: function () { return getOperationFacts_1.getOperationASTFacts; } });
Object.defineProperty(exports, "getQueryFacts", { enumerable: true, get: function () { return getOperationFacts_1.getQueryFacts; } });
export { getFragmentDependencies, getFragmentDependenciesForAST, } from './fragmentDependencies';
export { getVariablesJSONSchema, } from './getVariablesJSONSchema';
export { getASTNodeAtPosition, pointToOffset } from './getASTNodeAtPosition';
export { Position, Range, locToRange, offsetToPosition } from './Range';
export { validateWithCustomRules } from './validateWithCustomRules';
export { collectVariables } from './collectVariables';
export { default as getOperationFacts, getOperationASTFacts, getQueryFacts, } from './getOperationFacts';
//# sourceMappingURL=index.js.map

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

import { Location } from 'graphql/language';
import { Location } from 'graphql';
import { IRange, IPosition } from '../types';

@@ -3,0 +3,0 @@ export declare class Range implements IRange {

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.locToRange = exports.offsetToPosition = exports.Position = exports.Range = void 0;
class Range {
export class Range {
constructor(start, end) {

@@ -25,4 +22,3 @@ this.containsPosition = (position) => {

}
exports.Range = Range;
class Position {
export class Position {
constructor(line, character) {

@@ -41,4 +37,3 @@ this.lessThanOrEqualTo = (position) => this.line < position.line ||

}
exports.Position = Position;
function offsetToPosition(text, loc) {
export function offsetToPosition(text, loc) {
const EOL = '\n';

@@ -50,4 +45,3 @@ const buf = text.slice(0, loc);

}
exports.offsetToPosition = offsetToPosition;
function locToRange(text, loc) {
export function locToRange(text, loc) {
const start = offsetToPosition(text, loc.start);

@@ -57,3 +51,2 @@ const end = offsetToPosition(text, loc.end);

}
exports.locToRange = locToRange;
//# sourceMappingURL=Range.js.map

@@ -1,25 +0,22 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateWithCustomRules = void 0;
const graphql_1 = require("graphql");
import { specifiedRules, validate, NoUnusedFragmentsRule, KnownFragmentNamesRule, Kind, ExecutableDefinitionsRule, LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueDirectiveNamesRule, KnownTypeNamesRule, KnownDirectivesRule, UniqueDirectivesPerLocationRule, PossibleTypeExtensionsRule, UniqueArgumentNamesRule, UniqueInputFieldNamesRule, } from 'graphql';
const specifiedSDLRules = [
graphql_1.LoneSchemaDefinitionRule,
graphql_1.UniqueOperationTypesRule,
graphql_1.UniqueTypeNamesRule,
graphql_1.UniqueEnumValueNamesRule,
graphql_1.UniqueFieldDefinitionNamesRule,
graphql_1.UniqueDirectiveNamesRule,
graphql_1.KnownTypeNamesRule,
graphql_1.KnownDirectivesRule,
graphql_1.UniqueDirectivesPerLocationRule,
graphql_1.PossibleTypeExtensionsRule,
graphql_1.UniqueArgumentNamesRule,
graphql_1.UniqueInputFieldNamesRule,
LoneSchemaDefinitionRule,
UniqueOperationTypesRule,
UniqueTypeNamesRule,
UniqueEnumValueNamesRule,
UniqueFieldDefinitionNamesRule,
UniqueDirectiveNamesRule,
KnownTypeNamesRule,
KnownDirectivesRule,
UniqueDirectivesPerLocationRule,
PossibleTypeExtensionsRule,
UniqueArgumentNamesRule,
UniqueInputFieldNamesRule,
];
function validateWithCustomRules(schema, ast, customRules, isRelayCompatMode, isSchemaDocument) {
const rules = graphql_1.specifiedRules.filter(rule => {
if (rule === graphql_1.NoUnusedFragmentsRule || rule === graphql_1.ExecutableDefinitionsRule) {
export function validateWithCustomRules(schema, ast, customRules, isRelayCompatMode, isSchemaDocument) {
const rules = specifiedRules.filter(rule => {
if (rule === NoUnusedFragmentsRule || rule === ExecutableDefinitionsRule) {
return false;
}
if (isRelayCompatMode && rule === graphql_1.KnownFragmentNamesRule) {
if (isRelayCompatMode && rule === KnownFragmentNamesRule) {
return false;

@@ -35,7 +32,7 @@ }

}
const errors = (0, graphql_1.validate)(schema, ast, rules);
const errors = validate(schema, ast, rules);
return errors.filter(error => {
if (error.message.includes('Unknown directive') && error.nodes) {
const node = error.nodes[0];
if (node && node.kind === graphql_1.Kind.DIRECTIVE) {
if (node && node.kind === Kind.DIRECTIVE) {
const name = node.name.value;

@@ -50,3 +47,2 @@ if (name === 'arguments' || name === 'argumentDefinitions') {

}
exports.validateWithCustomRules = validateWithCustomRules;
//# sourceMappingURL=validateWithCustomRules.js.map
{
"name": "graphql-language-service",
"version": "5.2.0-canary-f5992ff0.0",
"version": "6.0.0-canary-298f53ab.0",
"description": "The official, runtime independent Language Service for GraphQL",

@@ -19,5 +19,3 @@ "contributors": [

"files": [
"dist",
"esm",
"src"
"dist"
],

@@ -29,4 +27,3 @@ "keywords": [

],
"main": "dist/index.js",
"module": "esm/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",

@@ -43,2 +40,5 @@ "bin": {

},
"engines": {
"node": ">=16"
},
"devDependencies": {

@@ -45,0 +45,0 @@ "@types/picomatch": "^2.3.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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc