diff --git a/.changeset/beige-worms-joke.md b/.changeset/beige-worms-joke.md new file mode 100644 index 00000000..e700bb19 --- /dev/null +++ b/.changeset/beige-worms-joke.md @@ -0,0 +1,5 @@ +--- +'@0no-co/graphqlsp': patch +--- + +Add fragments to the cache-key when using call-expressions diff --git a/packages/graphqlsp/src/diagnostics.ts b/packages/graphqlsp/src/diagnostics.ts index 7faae61b..9c1084c0 100644 --- a/packages/graphqlsp/src/diagnostics.ts +++ b/packages/graphqlsp/src/diagnostics.ts @@ -6,6 +6,7 @@ import { Kind, OperationDefinitionNode, parse, + print, } from 'graphql'; import { LRUCache } from 'lru-cache'; import fnv1a from '@sindresorhus/fnv1a'; @@ -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 {