Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-language-service

Package Overview
Dependencies
Maintainers
14
Versions
243
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.3 to 5.1.4

8

dist/interface/getAutocompleteSuggestions.js

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

const possibleIfaceMap = Object.create(null);
possibleObjTypes.forEach(type => {
type.getInterfaces().forEach(iface => {
for (const type of possibleObjTypes) {
for (const iface of type.getInterfaces()) {
possibleIfaceMap[iface.name] = iface;
});
});
}
}
possibleTypes = possibleObjTypes.concat((0, autocompleteUtils_1.objectValues)(possibleIfaceMap));

@@ -454,0 +454,0 @@ }

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

function getDefinitionQueryResultForField(fieldName, typeName, dependencies) {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -53,10 +54,9 @@ const defNodes = dependencies.filter(({ definition }) => definition.name && definition.name.value === typeName);

const definitions = [];
defNodes.forEach(({ filePath, content, definition }) => {
var _a;
for (const { filePath, content, definition } of defNodes) {
const fieldDefinition = (_a = definition.fields) === null || _a === void 0 ? void 0 : _a.find(item => item.name.value === fieldName);
if (fieldDefinition == null) {
return null;
continue;
}
definitions.push(getDefinitionForFieldDefinition(filePath || '', content, fieldDefinition));
});
}
return {

@@ -63,0 +63,0 @@ definitions,

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

const highlightedNodes = [];
error.nodes.forEach((node, i) => {
for (const [i, node] of error.nodes.entries()) {
const highlightNode = node.kind !== 'Variable' && 'name' in node && node.name !== undefined

@@ -90,3 +90,3 @@ ? node.name

}
});
}
return highlightedNodes;

@@ -93,0 +93,0 @@ }

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

const variableToType = Object.create(null);
documentAST.definitions.forEach(definition => {
for (const definition of documentAST.definitions) {
if (definition.kind === 'OperationDefinition') {
const { variableDefinitions } = definition;
if (variableDefinitions) {
variableDefinitions.forEach(({ variable, type }) => {
for (const { variable, type } of variableDefinitions) {
const inputType = (0, graphql_1.typeFromAST)(schema, type);

@@ -21,6 +21,6 @@ if (inputType) {

}
});
}
}
}
});
}
return variableToType;

@@ -27,0 +27,0 @@ }

@@ -40,9 +40,9 @@ "use strict";

const asts = new Set();
referencedFragNames.forEach(name => {
for (const name of referencedFragNames) {
if (!existingFrags.has(name) && fragmentDefinitions.has(name)) {
asts.add((0, nullthrows_1.default)(fragmentDefinitions.get(name)));
}
});
}
const referencedFragments = [];
asts.forEach(ast => {
for (const ast of asts) {
(0, graphql_1.visit)(ast, {

@@ -60,3 +60,3 @@ FragmentSpread(node) {

}
});
}
return referencedFragments;

@@ -63,0 +63,0 @@ };

@@ -80,5 +80,5 @@ "use strict";

if (defs) {
Object.keys(defs).forEach(defName => {
for (const defName of Object.keys(defs)) {
definitions[defName] = defs[defName];
});
}
}

@@ -91,5 +91,5 @@ }

if (defs) {
Object.keys(defs).forEach(defName => {
for (const defName of Object.keys(defs)) {
definitions[defName] = defs[defName];
});
}
}

@@ -120,3 +120,3 @@ }

}
Object.keys(fields).forEach(fieldName => {
for (const fieldName of Object.keys(fields)) {
const field = fields[fieldName];

@@ -140,7 +140,7 @@ const { required: fieldRequired, definition: typeDefinition, definitions: typeDefinitions, } = getJSONSchemaFromGraphQLType(field.type, options);

if (typeDefinitions) {
Object.keys(typeDefinitions).map(defName => {
definitions[defName] = typeDefinitions[defName];
});
for (const [defName, value] of Object.entries(typeDefinitions)) {
definitions[defName] = value;
}
}
});
}
definitions[type.name] = fieldDef;

@@ -168,2 +168,3 @@ }

function getVariablesJSONSchema(variableToType, options) {
var _a;
const jsonSchema = {

@@ -177,4 +178,3 @@ $schema: 'https://json-schema.org/draft/2020-12/schema',

if (variableToType) {
Object.entries(variableToType).forEach(([variableName, type]) => {
var _a;
for (const [variableName, type] of Object.entries(variableToType)) {
const { definition, required, definitions } = getJSONSchemaFromGraphQLType(type, runtimeOptions);

@@ -188,3 +188,3 @@ jsonSchema.properties[variableName] = definition;

}
});
}
}

@@ -191,0 +191,0 @@ return jsonSchema;

@@ -443,7 +443,7 @@ 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 possibleIfaceMap = Object.create(null);
possibleObjTypes.forEach(type => {
type.getInterfaces().forEach(iface => {
for (const type of possibleObjTypes) {
for (const iface of type.getInterfaces()) {
possibleIfaceMap[iface.name] = iface;
});
});
}
}
possibleTypes = possibleObjTypes.concat(objectValues(possibleIfaceMap));

@@ -450,0 +450,0 @@ }

@@ -42,2 +42,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

export function getDefinitionQueryResultForField(fieldName, typeName, dependencies) {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -49,10 +50,9 @@ const defNodes = dependencies.filter(({ definition }) => definition.name && definition.name.value === typeName);

const definitions = [];
defNodes.forEach(({ filePath, content, definition }) => {
var _a;
for (const { filePath, content, definition } of defNodes) {
const fieldDefinition = (_a = definition.fields) === null || _a === void 0 ? void 0 : _a.find(item => item.name.value === fieldName);
if (fieldDefinition == null) {
return null;
continue;
}
definitions.push(getDefinitionForFieldDefinition(filePath || '', content, fieldDefinition));
});
}
return {

@@ -59,0 +59,0 @@ definitions,

@@ -66,3 +66,3 @@ import { GraphQLError, print, validate, NoDeprecatedCustomRule, parse, } from 'graphql';

const highlightedNodes = [];
error.nodes.forEach((node, i) => {
for (const [i, node] of error.nodes.entries()) {
const highlightNode = node.kind !== 'Variable' && 'name' in node && node.name !== undefined

@@ -85,3 +85,3 @@ ? node.name

}
});
}
return highlightedNodes;

@@ -88,0 +88,0 @@ }

import { typeFromAST, GraphQLFloat, Kind, } from 'graphql';
export function collectVariables(schema, documentAST) {
const variableToType = Object.create(null);
documentAST.definitions.forEach(definition => {
for (const definition of documentAST.definitions) {
if (definition.kind === 'OperationDefinition') {
const { variableDefinitions } = definition;
if (variableDefinitions) {
variableDefinitions.forEach(({ variable, type }) => {
for (const { variable, type } of variableDefinitions) {
const inputType = typeFromAST(schema, type);

@@ -17,8 +17,8 @@ if (inputType) {

}
});
}
}
}
});
}
return variableToType;
}
//# sourceMappingURL=collectVariables.js.map

@@ -33,9 +33,9 @@ import { parse, visit } from 'graphql';

const asts = new Set();
referencedFragNames.forEach(name => {
for (const name of referencedFragNames) {
if (!existingFrags.has(name) && fragmentDefinitions.has(name)) {
asts.add(nullthrows(fragmentDefinitions.get(name)));
}
});
}
const referencedFragments = [];
asts.forEach(ast => {
for (const ast of asts) {
visit(ast, {

@@ -53,5 +53,5 @@ FragmentSpread(node) {

}
});
}
return referencedFragments;
};
//# sourceMappingURL=fragmentDependencies.js.map

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

if (defs) {
Object.keys(defs).forEach(defName => {
for (const defName of Object.keys(defs)) {
definitions[defName] = defs[defName];
});
}
}

@@ -88,5 +88,5 @@ }

if (defs) {
Object.keys(defs).forEach(defName => {
for (const defName of Object.keys(defs)) {
definitions[defName] = defs[defName];
});
}
}

@@ -117,3 +117,3 @@ }

}
Object.keys(fields).forEach(fieldName => {
for (const fieldName of Object.keys(fields)) {
const field = fields[fieldName];

@@ -137,7 +137,7 @@ const { required: fieldRequired, definition: typeDefinition, definitions: typeDefinitions, } = getJSONSchemaFromGraphQLType(field.type, options);

if (typeDefinitions) {
Object.keys(typeDefinitions).map(defName => {
definitions[defName] = typeDefinitions[defName];
});
for (const [defName, value] of Object.entries(typeDefinitions)) {
definitions[defName] = value;
}
}
});
}
definitions[type.name] = fieldDef;

@@ -165,2 +165,3 @@ }

export function getVariablesJSONSchema(variableToType, options) {
var _a;
const jsonSchema = {

@@ -174,4 +175,3 @@ $schema: 'https://json-schema.org/draft/2020-12/schema',

if (variableToType) {
Object.entries(variableToType).forEach(([variableName, type]) => {
var _a;
for (const [variableName, type] of Object.entries(variableToType)) {
const { definition, required, definitions } = getJSONSchemaFromGraphQLType(type, runtimeOptions);

@@ -185,3 +185,3 @@ jsonSchema.properties[variableName] = definition;

}
});
}
}

@@ -188,0 +188,0 @@ return jsonSchema;

{
"name": "graphql-language-service",
"version": "5.1.3",
"version": "5.1.4",
"description": "The official, runtime independent Language Service for GraphQL",

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

@@ -749,7 +749,7 @@ /**

const possibleIfaceMap = Object.create(null);
possibleObjTypes.forEach(type => {
type.getInterfaces().forEach(iface => {
for (const type of possibleObjTypes) {
for (const iface of type.getInterfaces()) {
possibleIfaceMap[iface.name] = iface;
});
});
}
}
possibleTypes = possibleObjTypes.concat(objectValues(possibleIfaceMap));

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

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

defNodes.forEach(({ filePath, content, definition }) => {
for (const { filePath, content, definition } of defNodes) {
const fieldDefinition = (

@@ -97,3 +97,3 @@ definition as ObjectTypeDefinitionNode

if (fieldDefinition == null) {
return null;
continue;
}

@@ -104,3 +104,3 @@

);
});
}

@@ -107,0 +107,0 @@ return {

@@ -141,3 +141,3 @@ /**

const highlightedNodes: Diagnostic[] = [];
error.nodes.forEach((node, i) => {
for (const [i, node] of error.nodes.entries()) {
const highlightNode =

@@ -170,3 +170,3 @@ node.kind !== 'Variable' && 'name' in node && node.name !== undefined

}
});
}
return highlightedNodes;

@@ -173,0 +173,0 @@ }

@@ -130,4 +130,3 @@ import OnlineParser from '../onlineParser';

export const performForEachType = (source, test) => {
Object.keys(typesMap).map(type => {
const { value, kind, valueType } = typesMap[type];
for (const [type, { value, kind, valueType }] of Object.entries(typesMap)) {
const utils = getUtils(

@@ -137,3 +136,3 @@ source.replaceAll('__VALUE__', value).replaceAll('__TYPE__', type),

test(utils, { type, value, kind, valueType });
});
}
};

@@ -147,3 +146,3 @@

vars.forEach(variable => {
for (const variable of vars) {
t.variable('$', { kind: 'Variable' });

@@ -155,3 +154,3 @@ t.variable(variable.name);

stream.eatWhile(/(,|\s)/);
});
}

@@ -167,3 +166,3 @@ t.punctuation(/\)/, { kind: onKind });

args.forEach(arg => {
for (const arg of args) {
t.attribute(arg.name, { kind: 'Argument' });

@@ -185,3 +184,3 @@ t.punctuation(':');

stream.eatWhile(/(,|\s)/);
});
}

@@ -188,0 +187,0 @@ t.punctuation(/\)/, { kind: onKind });

@@ -29,7 +29,7 @@ import {

// it would be more ideal to use visitWithTypeInfo here but it's very simple
documentAST.definitions.forEach(definition => {
for (const definition of documentAST.definitions) {
if (definition.kind === 'OperationDefinition') {
const { variableDefinitions } = definition;
if (variableDefinitions) {
variableDefinitions.forEach(({ variable, type }) => {
for (const { variable, type } of variableDefinitions) {
const inputType = typeFromAST(

@@ -48,7 +48,7 @@ schema,

}
});
}
}
}
});
}
return variableToType;
}

@@ -54,11 +54,11 @@ /**

const asts = new Set<FragmentDefinitionNode>();
referencedFragNames.forEach(name => {
for (const name of referencedFragNames) {
if (!existingFrags.has(name) && fragmentDefinitions.has(name)) {
asts.add(nullthrows(fragmentDefinitions.get(name)));
}
});
}
const referencedFragments: FragmentDefinitionNode[] = [];
asts.forEach(ast => {
for (const ast of asts) {
visit(ast, {

@@ -78,5 +78,5 @@ FragmentSpread(node) {

}
});
}
return referencedFragments;
};

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

private set = new Set<string>();
mark(name: string): boolean {

@@ -162,5 +163,5 @@ if (this.set.has(name)) {

if (defs) {
Object.keys(defs).forEach(defName => {
for (const defName of Object.keys(defs)) {
definitions[defName] = defs[defName];
});
}
}

@@ -176,5 +177,5 @@ }

if (defs) {
Object.keys(defs).forEach(defName => {
for (const defName of Object.keys(defs)) {
definitions[defName] = defs[defName];
});
}
}

@@ -208,3 +209,3 @@ }

Object.keys(fields).forEach(fieldName => {
for (const fieldName of Object.keys(fields)) {
const field = fields[fieldName];

@@ -245,7 +246,7 @@ const {

if (typeDefinitions) {
Object.keys(typeDefinitions).map(defName => {
definitions[defName] = typeDefinitions[defName];
});
for (const [defName, value] of Object.entries(typeDefinitions)) {
definitions[defName] = value;
}
}
});
}
definitions[type.name] = fieldDef;

@@ -277,2 +278,3 @@ }

}
/**

@@ -333,3 +335,3 @@ * Generates a JSONSchema6 valid document for operation(s) from a map of Map<string, GraphQLInputType>.

// I would use a reduce here, but I wanted it to be readable.
Object.entries(variableToType).forEach(([variableName, type]) => {
for (const [variableName, type] of Object.entries(variableToType)) {
const { definition, required, definitions } =

@@ -344,5 +346,5 @@ getJSONSchemaFromGraphQLType(type, runtimeOptions);

}
});
}
}
return jsonSchema;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc