Skip to content

Commit

Permalink
update cache key to include fragments with call expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Dec 9, 2023
1 parent 6e0b8cd commit f22d21e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/beige-worms-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@0no-co/graphqlsp': patch
---

Add fragments to the cache-key when using call-expressions
9 changes: 8 additions & 1 deletion packages/graphqlsp/src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Kind,
OperationDefinitionNode,
parse,
print,
} from 'graphql';
import { LRUCache } from 'lru-cache';
import fnv1a from '@sindresorhus/fnv1a';
Expand Down Expand Up @@ -75,7 +76,13 @@ export function getGraphQLDiagnostics(
});

let tsDiagnostics: ts.Diagnostic[] = [];
const cacheKey = fnv1a(texts.join('-') + schema.version);
const cacheKey = fnv1a(
isCallExpression
? texts.join('-') +
fragments.map(x => print(x)).join('-') +
schema.version
: texts.join('-') + schema.version
);
if (cache.has(cacheKey)) {
tsDiagnostics = cache.get(cacheKey)!;
} else {
Expand Down

0 comments on commit f22d21e

Please sign in to comment.