Skip to content

Commit

Permalink
Remove missing operation name (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Oct 5, 2024
1 parent b2a98a8 commit 6d9ce44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-doors-move.md
Original file line number Diff line number Diff line change
@@ -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
24 changes: 0 additions & 24 deletions packages/graphqlsp/src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ 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;
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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6d9ce44

Please sign in to comment.