Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not destructure Kind from graphql #3085

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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