Skip to content

Commit

Permalink
do not destructure Kind from graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Mar 6, 2023
1 parent 5cf77e0 commit 71ea047
Showing 1 changed file with 22 additions and 40 deletions.
62 changes: 22 additions & 40 deletions packages/graphql-language-service-server/src/GraphQLCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@ import { Logger } from './Logger';
// Maximum files to read when processing GraphQL files.
const MAX_READS = 200;

const {
DOCUMENT,
FRAGMENT_DEFINITION,
OBJECT_TYPE_DEFINITION,
INTERFACE_TYPE_DEFINITION,
ENUM_TYPE_DEFINITION,
UNION_TYPE_DEFINITION,
SCALAR_TYPE_DEFINITION,
INPUT_OBJECT_TYPE_DEFINITION,
SCALAR_TYPE_EXTENSION,
OBJECT_TYPE_EXTENSION,
INTERFACE_TYPE_EXTENSION,
UNION_TYPE_EXTENSION,
ENUM_TYPE_EXTENSION,
INPUT_OBJECT_TYPE_EXTENSION,
DIRECTIVE_DEFINITION,
} = Kind;

export async function getGraphQLCache({
parser,
logger,
Expand Down Expand Up @@ -439,7 +421,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
return;
}
ast.definitions.forEach(definition => {
if (definition.kind === FRAGMENT_DEFINITION) {
if (definition.kind === Kind.FRAGMENT_DEFINITION) {
cache.set(definition.name.value, {
filePath,
content: query,
Expand Down Expand Up @@ -502,9 +484,9 @@ export class GraphQLCache implements GraphQLCacheInterface {
}
ast.definitions.forEach(definition => {
if (
definition.kind === OBJECT_TYPE_DEFINITION ||
definition.kind === INPUT_OBJECT_TYPE_DEFINITION ||
definition.kind === ENUM_TYPE_DEFINITION
definition.kind === Kind.OBJECT_TYPE_DEFINITION ||
definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ||
definition.kind === Kind.ENUM_TYPE_DEFINITION
) {
cache.set(definition.name.value, {
filePath,
Expand Down Expand Up @@ -561,19 +543,19 @@ export class GraphQLCache implements GraphQLCacheInterface {
}
ast.definitions.forEach(definition => {
switch (definition.kind) {
case OBJECT_TYPE_DEFINITION:
case INTERFACE_TYPE_DEFINITION:
case ENUM_TYPE_DEFINITION:
case UNION_TYPE_DEFINITION:
case SCALAR_TYPE_DEFINITION:
case INPUT_OBJECT_TYPE_DEFINITION:
case SCALAR_TYPE_EXTENSION:
case OBJECT_TYPE_EXTENSION:
case INTERFACE_TYPE_EXTENSION:
case UNION_TYPE_EXTENSION:
case ENUM_TYPE_EXTENSION:
case INPUT_OBJECT_TYPE_EXTENSION:
case DIRECTIVE_DEFINITION:
case Kind.OBJECT_TYPE_DEFINITION:
case Kind.INTERFACE_TYPE_DEFINITION:
case Kind.ENUM_TYPE_DEFINITION:
case Kind.UNION_TYPE_DEFINITION:
case Kind.SCALAR_TYPE_DEFINITION:
case Kind.INPUT_OBJECT_TYPE_DEFINITION:
case Kind.SCALAR_TYPE_EXTENSION:
case Kind.OBJECT_TYPE_EXTENSION:
case Kind.INTERFACE_TYPE_EXTENSION:
case Kind.UNION_TYPE_EXTENSION:
case Kind.ENUM_TYPE_EXTENSION:
case Kind.INPUT_OBJECT_TYPE_EXTENSION:
case Kind.DIRECTIVE_DEFINITION:
typeExtensions.push(definition);
break;
}
Expand All @@ -600,7 +582,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
}

return extendSchema(schema, {
kind: DOCUMENT,
kind: Kind.DOCUMENT,
definitions: typeExtensions,
});
}
Expand Down Expand Up @@ -746,17 +728,17 @@ export class GraphQLCache implements GraphQLCacheInterface {
if (asts) {
asts.forEach(ast => {
ast.definitions.forEach(definition => {
if (definition.kind === FRAGMENT_DEFINITION) {
if (definition.kind === Kind.FRAGMENT_DEFINITION) {
fragmentDefinitions.set(definition.name.value, {
filePath,
content,
definition,
});
}
if (
definition.kind === OBJECT_TYPE_DEFINITION ||
definition.kind === INPUT_OBJECT_TYPE_DEFINITION ||
definition.kind === ENUM_TYPE_DEFINITION
definition.kind === Kind.OBJECT_TYPE_DEFINITION ||
definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ||
definition.kind === Kind.ENUM_TYPE_DEFINITION
) {
objectTypeDefinitions.set(definition.name.value, {
filePath,
Expand Down

0 comments on commit 71ea047

Please sign in to comment.