Socket
Socket
Sign inDemoInstall

graphql-language-service

Package Overview
Dependencies
Maintainers
14
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service - npm Package Compare versions

Comparing version 5.1.6 to 5.1.7-alpha.0

2

dist/interface/getAutocompleteSuggestions.d.ts

@@ -17,3 +17,3 @@ import { FragmentDefinitionNode, GraphQLDirective, GraphQLSchema } from 'graphql';

export declare function getFragmentDefinitions(queryText: string): Array<FragmentDefinitionNode>;
export declare function getTokenAtPosition(queryText: string, cursor: IPosition): ContextToken;
export declare function getTokenAtPosition(queryText: string, cursor: IPosition, offset?: number): ContextToken;
declare type callbackFnType = (stream: CharacterStream, state: State, style: string, index: number) => void | 'BREAK';

@@ -20,0 +20,0 @@ export declare function runOnlineParser(queryText: string, callback: callbackFnType): ContextToken;

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

const opts = Object.assign(Object.assign({}, options), { schema });
const token = contextToken || getTokenAtPosition(queryText, cursor);
const token = contextToken || getTokenAtPosition(queryText, cursor, 1);
const state = token.state.kind === 'Invalid' ? token.state.prevState : token.state;

@@ -246,3 +246,3 @@ const mode = (options === null || options === void 0 ? void 0 : options.mode) || getDocumentMode(queryText, options === null || options === void 0 ? void 0 : options.uri);

exports.getAutocompleteSuggestions = getAutocompleteSuggestions;
const insertSuffix = ` {\n $1\n}`;
const insertSuffix = ' {\n $1\n}';
const getInsertText = (field) => {

@@ -594,3 +594,3 @@ const { type } = field;

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

@@ -601,3 +601,3 @@ let stateAtCursor = null;

if (index === cursor.line &&
stream.getCurrentPosition() >= cursor.character) {
stream.getCurrentPosition() + offset >= cursor.character + 1) {
styleAtCursor = style;

@@ -604,0 +604,0 @@ stateAtCursor = Object.assign({}, state);

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

fieldDef.description =
type.description + `\n` + renderTypeToString(type);
type.description + '\n' + renderTypeToString(type);
if (options === null || options === void 0 ? void 0 : options.useMarkdownDescription) {
fieldDef.markdownDescription =
type.description + `\n` + renderTypeToString(type, true);
type.description + '\n' + renderTypeToString(type, true);
}

@@ -112,0 +112,0 @@ }

@@ -17,3 +17,3 @@ import { FragmentDefinitionNode, GraphQLDirective, GraphQLSchema } from 'graphql';

export declare function getFragmentDefinitions(queryText: string): Array<FragmentDefinitionNode>;
export declare function getTokenAtPosition(queryText: string, cursor: IPosition): ContextToken;
export declare function getTokenAtPosition(queryText: string, cursor: IPosition, offset?: number): ContextToken;
declare type callbackFnType = (stream: CharacterStream, state: State, style: string, index: number) => void | 'BREAK';

@@ -20,0 +20,0 @@ export declare function runOnlineParser(queryText: string, callback: callbackFnType): ContextToken;

@@ -69,3 +69,3 @@ 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';

const opts = Object.assign(Object.assign({}, options), { schema });
const token = contextToken || getTokenAtPosition(queryText, cursor);
const token = contextToken || getTokenAtPosition(queryText, cursor, 1);
const state = token.state.kind === 'Invalid' ? token.state.prevState : token.state;

@@ -242,3 +242,3 @@ const mode = (options === null || options === void 0 ? void 0 : options.mode) || getDocumentMode(queryText, options === null || options === void 0 ? void 0 : options.uri);

}
const insertSuffix = ` {\n $1\n}`;
const insertSuffix = ' {\n $1\n}';
const getInsertText = (field) => {

@@ -588,3 +588,3 @@ const { type } = field;

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

@@ -595,3 +595,3 @@ let stateAtCursor = null;

if (index === cursor.line &&
stream.getCurrentPosition() >= cursor.character) {
stream.getCurrentPosition() + offset >= cursor.character + 1) {
styleAtCursor = style;

@@ -598,0 +598,0 @@ stateAtCursor = Object.assign({}, state);

@@ -103,6 +103,6 @@ import { isEnumType, isInputObjectType, isListType, isNonNullType, isScalarType, } from 'graphql';

fieldDef.description =
type.description + `\n` + renderTypeToString(type);
type.description + '\n' + renderTypeToString(type);
if (options === null || options === void 0 ? void 0 : options.useMarkdownDescription) {
fieldDef.markdownDescription =
type.description + `\n` + renderTypeToString(type, true);
type.description + '\n' + renderTypeToString(type, true);
}

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

{
"name": "graphql-language-service",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "The official, runtime independent Language Service for GraphQL",

@@ -5,0 +5,0 @@ "contributors": [

@@ -123,3 +123,3 @@ /**

schema,
`{ h`,
'{ h',
new Position(0, 3),

@@ -601,3 +601,3 @@ ).map(({ sortText, label, detail }) => ({ sortText, label, detail }));

expect(
testSuggestions(`type Type {\n aField: s`, new Position(0, 23), [], {
testSuggestions('type Type {\n aField: s', new Position(0, 23), [], {
uri: 'schema.graphqls',

@@ -614,3 +614,3 @@ }),

expect(
testSuggestions(`type Type {\n aField: []`, new Position(0, 25), [], {
testSuggestions('type Type {\n aField: []', new Position(0, 25), [], {
uri: 'schema.graphqls',

@@ -634,3 +634,3 @@ }),

expect(
testSuggestions(`input Type {\n aField: s`, new Position(0, 23), [], {
testSuggestions('input Type {\n aField: s', new Position(0, 23), [], {
uri: 'schema.graphqls',

@@ -637,0 +637,0 @@ }),

@@ -90,3 +90,3 @@ /**

validationContext.reportError(
new GraphQLError(`This is a custom error.`, definition),
new GraphQLError('This is a custom error.', definition),
);

@@ -166,3 +166,3 @@ }

});
const errors = getDiagnostics(`query hero { hero { id } }`, schema, [
const errors = getDiagnostics('query hero { hero { id } }', schema, [
noQueryRule,

@@ -176,3 +176,3 @@ ]);

const errors = getDiagnostics(
`query hero { hero { ...HeroGuy } }`,
'query hero { hero { ...HeroGuy } }',
schema,

@@ -195,3 +195,3 @@ [],

const errors = getDiagnostics(
`query hero { hero { ...Person ...Person2 } }`,
'query hero { hero { ...Person ...Person2 } }',
schema,

@@ -198,0 +198,0 @@ [],

@@ -168,3 +168,3 @@ /**

const token: ContextToken =
contextToken || getTokenAtPosition(queryText, cursor);
contextToken || getTokenAtPosition(queryText, cursor, 1);

@@ -361,3 +361,3 @@ const state =

if (kind === RuleKinds.VARIABLE && step === 1) {
const namedInputType = getNamedType(typeInfo.inputType as GraphQLType);
const namedInputType = getNamedType(typeInfo.inputType!);
const variableDefinitions = getVariableCompletions(

@@ -455,3 +455,3 @@ queryText,

const insertSuffix = ` {\n $1\n}`;
const insertSuffix = ' {\n $1\n}';

@@ -576,3 +576,3 @@ /**

): Array<CompletionItem> {
const namedInputType = getNamedType(typeInfo.inputType as GraphQLType);
const namedInputType = getNamedType(typeInfo.inputType!);

@@ -939,3 +939,3 @@ const queryVariables: CompletionItem[] = getVariableCompletions(

label: type.name,
documentation: type.description as string,
documentation: type.description!,
kind: CompletionItemKind.Variable,

@@ -971,2 +971,3 @@ })),

cursor: IPosition,
offset = 0,
): ContextToken {

@@ -979,3 +980,3 @@ let styleAtCursor = null;

index === cursor.line &&
stream.getCurrentPosition() >= cursor.character
stream.getCurrentPosition() + offset >= cursor.character + 1
) {

@@ -1159,3 +1160,3 @@ styleAtCursor = style;

case RuleKinds.SELECTION_SET:
parentType = getNamedType(type as GraphQLType);
parentType = getNamedType(type!);
break;

@@ -1238,3 +1239,3 @@ case RuleKinds.DIRECTIVE:

case RuleKinds.ENUM_VALUE:
const enumType = getNamedType(inputType as GraphQLType);
const enumType = getNamedType(inputType!);
enumValue =

@@ -1249,3 +1250,3 @@ enumType instanceof GraphQLEnumType

case RuleKinds.LIST_VALUE:
const nullableType = getNullableType(inputType as GraphQLType);
const nullableType = getNullableType(inputType!);
inputType =

@@ -1255,3 +1256,3 @@ nullableType instanceof GraphQLList ? nullableType.ofType : null;

case RuleKinds.OBJECT_VALUE:
const objectType = getNamedType(inputType as GraphQLType);
const objectType = getNamedType(inputType!);
objectFieldDefs =

@@ -1258,0 +1259,0 @@ objectType instanceof GraphQLInputObjectType

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

TypeDefinitionNode,
Location,
ObjectTypeDefinitionNode,

@@ -41,3 +40,3 @@ FieldDefinitionNode,

function getRange(text: string, node: ASTNode): Range {
const location = node.loc as Location;
const location = node.loc!;
assert(location, 'Expected ASTNode to have a location.');

@@ -48,3 +47,3 @@ return locToRange(text, location);

function getPosition(text: string, node: ASTNode): Position {
const location = node.loc as Location;
const location = node.loc!;
assert(location, 'Expected ASTNode to have a location.');

@@ -51,0 +50,0 @@ return offsetToPosition(text, location.start);

@@ -114,3 +114,3 @@ /**

renderQualifiedField(into, typeInfo, options);
renderTypeAnnotation(into, typeInfo, options, typeInfo.type as GraphQLType);
renderTypeAnnotation(into, typeInfo, options, typeInfo.type!);
}

@@ -128,3 +128,3 @@

if (fieldName.slice(0, 2) !== '__') {
renderType(into, typeInfo, options, typeInfo.parentType as GraphQLType);
renderType(into, typeInfo, options, typeInfo.parentType!);
text(into, '.');

@@ -157,8 +157,3 @@ }

text(into, name);
renderTypeAnnotation(
into,
typeInfo,
options,
typeInfo.inputType as GraphQLType,
);
renderTypeAnnotation(into, typeInfo, options, typeInfo.inputType!);
text(into, ')');

@@ -182,3 +177,3 @@ }

const { name } = typeInfo.enumValue;
renderType(into, typeInfo, options, typeInfo.inputType as GraphQLType);
renderType(into, typeInfo, options, typeInfo.inputType!);
text(into, '.');

@@ -185,0 +180,0 @@ text(into, name);

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

it('detects invalid char', () => {
const { token } = getUtils(`^`);
const { token } = getUtils('^');

@@ -246,3 +246,3 @@ expect(token()).toEqual('invalidchar');

it(`parses query field with a directive and selection set`, () => {
it('parses query field with a directive and selection set', () => {
const { t } = getUtils(`

@@ -272,3 +272,3 @@ query SomeQuery {

it(`parses query field with an alias`, () => {
it('parses query field with an alias', () => {
const { t } = getUtils(`

@@ -300,3 +300,3 @@ query SomeQuery {

it(`parses invalid query`, () => {
it('parses invalid query', () => {
const { t, token } = getUtils(`

@@ -315,3 +315,3 @@ {}garbage

it(`parses a fragment definition`, () => {
it('parses a fragment definition', () => {
const { t } = getUtils(`

@@ -336,3 +336,3 @@ fragment SomeFragment on SomeType {

it(`parses a fragment definition with a directive`, () => {
it('parses a fragment definition with a directive', () => {
const { t } = getUtils(`

@@ -550,3 +550,3 @@ fragment SomeFragment on SomeType @someDirective {

it(`parses mutation field with a directive and selection set`, () => {
it('parses mutation field with a directive and selection set', () => {
const { t } = getUtils(`

@@ -576,3 +576,3 @@ mutation SomeMutation {

it(`parses mutation field with an alias`, () => {
it('parses mutation field with an alias', () => {
const { t } = getUtils(`

@@ -796,3 +796,3 @@ mutation SomeMutation {

it(`parses subscription field with a directive and selection set`, () => {
it('parses subscription field with a directive and selection set', () => {
const { t } = getUtils(`

@@ -822,3 +822,3 @@ subscription SomeSubscription {

it(`parses subscription field with an alias`, () => {
it('parses subscription field with an alias', () => {
const { t } = getUtils(`

@@ -912,3 +912,3 @@ subscription SomeSubscription {

describe('parses object type def', () => {
it(`correctly`, () => {
it('correctly', () => {
const { t } = getUtils(`

@@ -934,3 +934,3 @@ type SomeType {

it('with an object implementing an interface', () => {
const { t } = getUtils(`type SomeType implements SomeInterface`);
const { t } = getUtils('type SomeType implements SomeInterface');

@@ -947,3 +947,3 @@ t.keyword('type', { kind: 'ObjectTypeDef' });

const { t } = getUtils(
`type SomeType implements SomeInterface & AnotherInterface & YetAnotherInterface`,
'type SomeType implements SomeInterface & AnotherInterface & YetAnotherInterface',
);

@@ -963,3 +963,3 @@

it('with a directive', () => {
const { t } = getUtils(`type SomeType @someDirective`);
const { t } = getUtils('type SomeType @someDirective');

@@ -974,3 +974,3 @@ t.keyword('type', { kind: 'ObjectTypeDef' });

performForEachType(
`type SomeType @someDirective(someArg: __VALUE__)`,
'type SomeType @someDirective(someArg: __VALUE__)',
({ t, stream }, fill) => {

@@ -1017,3 +1017,3 @@ it(`with a directive having argument of type ${fill.type}`, () => {

it('with a directive', () => {
const { t } = getUtils(`interface SomeInterface @someDirective`);
const { t } = getUtils('interface SomeInterface @someDirective');

@@ -1029,3 +1029,3 @@ t.keyword('interface', { kind: 'InterfaceDef' });

const { t } = getUtils(
`interface AnInterface implements SomeInterface & AnotherInterface & YetAnotherInterface`,
'interface AnInterface implements SomeInterface & AnotherInterface & YetAnotherInterface',
);

@@ -1045,3 +1045,3 @@

performForEachType(
`interface SomeInterface @someDirective(someArg: __VALUE__)`,
'interface SomeInterface @someDirective(someArg: __VALUE__)',
({ t, stream }, fill) => {

@@ -1325,3 +1325,3 @@ it(`with a directive having argument of type ${fill.type}`, () => {

it('correctly', () => {
const { t } = getUtils(`scalar SomeScalar`);
const { t } = getUtils('scalar SomeScalar');

@@ -1335,3 +1335,3 @@ t.keyword('scalar', { kind: 'ScalarDef' });

it('with a directive', () => {
const { t } = getUtils(`scalar SomeScalar @someDirective`);
const { t } = getUtils('scalar SomeScalar @someDirective');

@@ -1348,3 +1348,3 @@ t.keyword('scalar', { kind: 'ScalarDef' });

it('correctly', () => {
const { t } = getUtils(`union SomeUnionType = SomeType | AnotherType`);
const { t } = getUtils('union SomeUnionType = SomeType | AnotherType');

@@ -1363,3 +1363,3 @@ t.keyword('union', { kind: 'UnionDef' });

const { t } = getUtils(
`union SomeUnionType @someDirective = SomeType | AnotherType`,
'union SomeUnionType @someDirective = SomeType | AnotherType',
);

@@ -1382,3 +1382,3 @@

const { t } = getUtils(
`directive @someDirective on FIELD_DEFINITION | ENUM_VALUE `,
'directive @someDirective on FIELD_DEFINITION | ENUM_VALUE ',
);

@@ -1385,0 +1385,0 @@

@@ -14,6 +14,6 @@ import OnlineParser from '../onlineParser';

const typesMap = {
ID: { value: `"1"`, kind: 'StringValue', valueType: 'String' },
ID: { value: '"1"', kind: 'StringValue', valueType: 'String' },
Int: { value: '1', kind: 'NumberValue', valueType: 'Number' },
Float: { value: '1.0', kind: 'NumberValue', valueType: 'Number' },
String: { value: `"abc"`, kind: 'StringValue', valueType: 'String' },
String: { value: '"abc"', kind: 'StringValue', valueType: 'String' },
Boolean: { value: 'true', kind: 'BooleanValue', valueType: 'Boolean' },

@@ -20,0 +20,0 @@ Enum: { value: 'ADMIN', kind: 'EnumValue', valueType: 'Enum' },

@@ -213,3 +213,3 @@ /**

},
description: `list type with default\n[ChildInputType]`,
description: 'list type with default\n[ChildInputType]',
markdownDescription: `list type with default\n${mdTicks(

@@ -216,0 +216,0 @@ '[ChildInputType]',

@@ -192,7 +192,7 @@ /**

fieldDef.description =
type.description + `\n` + renderTypeToString(type);
type.description + '\n' + renderTypeToString(type);
if (options?.useMarkdownDescription) {
// @ts-expect-error
fieldDef.markdownDescription =
type.description + `\n` + renderTypeToString(type, true);
type.description + '\n' + renderTypeToString(type, true);
}

@@ -199,0 +199,0 @@ } else {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc