···11+---
22+'@urql/core': patch
33+---
44+55+Fix mark `query.__key` as non-enumerable so `formatDocument` does not restore previous invocations when cloning the gql-ast.
+9
packages/core/src/utils/typenames.test.ts
···4949 expect(expectedKey).toBe(actualKey);
5050 });
51515252+ it('does not preserve the referential integrity with a cloned object', () => {
5353+ const doc = parse(`{ id todos { id } }`);
5454+ const formattedDoc = formatDocument(doc);
5555+ expect(formattedDoc).not.toBe(doc);
5656+ const query = { ...formattedDoc };
5757+ const reformattedDoc = formatDocument(query);
5858+ expect(reformattedDoc).not.toBe(doc);
5959+ });
6060+5261 it('preserves custom properties', () => {
5362 const doc = parse(`{ todos { id } }`) as any;
5463 doc.documentId = '123';
+9-1
packages/core/src/utils/typenames.ts
···7676 Field: formatNode,
7777 InlineFragment: formatNode,
7878 }) as KeyedDocumentNode;
7979+7980 // Ensure that the hash of the resulting document won't suddenly change
8080- result.__key = query.__key;
8181+ // we are marking __key as non-enumerable so when external exchanges use visit
8282+ // to manipulate a document we won't restore the previous query due to the __key
8383+ // property.
8484+ Object.defineProperty(result, '__key', {
8585+ value: query.__key,
8686+ enumerable: false,
8787+ });
8888+8189 formattedDocs.set(query.__key, result);
8290 }
8391