From 6d9ce44d46dc6adbaf387ad5c96e4125570c3a94 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Sat, 5 Oct 2024 10:30:03 +0200 Subject: [PATCH] Remove missing operation name (#362) --- .changeset/clean-doors-move.md | 5 +++++ packages/graphqlsp/src/diagnostics.ts | 24 ------------------------ 2 files changed, 5 insertions(+), 24 deletions(-) create mode 100644 .changeset/clean-doors-move.md diff --git a/.changeset/clean-doors-move.md b/.changeset/clean-doors-move.md new file mode 100644 index 00000000..08ef237d --- /dev/null +++ b/.changeset/clean-doors-move.md @@ -0,0 +1,5 @@ +--- +'@0no-co/graphqlsp': minor +--- + +Remove missing operation-name code, with our increased focus on not generating any code this becomes irrelevant diff --git a/packages/graphqlsp/src/diagnostics.ts b/packages/graphqlsp/src/diagnostics.ts index 44ca62d3..4d967c84 100644 --- a/packages/graphqlsp/src/diagnostics.ts +++ b/packages/graphqlsp/src/diagnostics.ts @@ -51,7 +51,6 @@ const clientDirectives = new Set([ ]); export const SEMANTIC_DIAGNOSTIC_CODE = 52001; -export const MISSING_OPERATION_NAME_CODE = 52002; export const USING_DEPRECATED_FIELD_CODE = 52004; export const MISSING_PERSISTED_TYPE_ARG = 520100; export const MISSING_PERSISTED_CODE_ARG = 520101; @@ -59,7 +58,6 @@ export const MISSING_PERSISTED_DOCUMENT = 520102; export const MISSMATCH_HASH_TO_DOCUMENT = 520103; export const ALL_DIAGNOSTICS = [ SEMANTIC_DIAGNOSTIC_CODE, - MISSING_OPERATION_NAME_CODE, USING_DEPRECATED_FIELD_CODE, MISSING_FRAGMENT_CODE, UNUSED_FIELD_CODE, @@ -493,28 +491,6 @@ const runDiagnostics = ( }) .filter(x => x.start + x.length <= endPosition); - try { - const parsed = parse(text, { noLocation: true }); - - if ( - parsed.definitions.some(x => x.kind === Kind.OPERATION_DEFINITION) - ) { - const op = parsed.definitions.find( - x => x.kind === Kind.OPERATION_DEFINITION - ) as OperationDefinitionNode; - if (!op.name) { - graphQLDiagnostics.push({ - message: 'Operation should contain a name.', - start: node.getStart(), - code: MISSING_OPERATION_NAME_CODE, - length: originalNode.node.getText().length, - range: {} as any, - severity: 2, - } as any); - } - } - } catch (e) {} - return graphQLDiagnostics; }) .flat()