Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

fix: deduplicate fragments when generating persisted document hash (#342)

Changed files
+13 -5
.changeset
packages
graphqlsp
+5
.changeset/stale-plums-prove.md
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
Fixed duplicate fragments in persisted document hash generator
+8 -5
packages/graphqlsp/src/persisted.ts
···
foundFilename,
info
).combinedText;
-
fragments.forEach(fragmentDefinition => {
-
text = `${text}\n\n${print(fragmentDefinition)}`;
+
const deduplicatedFragments = fragments
+
.map(fragment => print(fragment))
+
.filter((fragment, index, array) => array.indexOf(fragment) === index);
+
+
deduplicatedFragments.forEach(fragmentDefinition => {
+
text = `${text}\n\n${fragmentDefinition}`;
});
-
return createHash('sha256')
-
.update(print(parse(text)))
-
.digest('hex');
+
const fullText = print(parse(text));
+
return createHash('sha256').update(fullText).digest('hex');
} else {
const externalSource = getSource(info, foundFilename)!;
const { fragments } = findAllCallExpressions(externalSource, info);