From e032398dd67ee5a1f9c0a27d371a912b6adac852 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 14 Aug 2024 16:03:11 -0600 Subject: [PATCH] Add failing test for watchFragment with non-identifiable object --- src/__tests__/ApolloClient.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/__tests__/ApolloClient.ts b/src/__tests__/ApolloClient.ts index bcf9978ef90..cb60a66c6e1 100644 --- a/src/__tests__/ApolloClient.ts +++ b/src/__tests__/ApolloClient.ts @@ -2515,6 +2515,36 @@ describe("ApolloClient", () => { }); } }); + + it("reports complete as false when `from` is not identifiable", async () => { + const cache = new InMemoryCache(); + const client = new ApolloClient({ + cache, + link: ApolloLink.empty(), + }); + const ItemFragment = gql` + fragment ItemFragment on Item { + id + text + } + `; + + const observable = client.watchFragment({ + fragment: ItemFragment, + from: {}, + }); + + const stream = new ObservableStream(observable); + + { + const result = await stream.takeNext(); + + expect(result).toStrictEqual({ + data: {}, + complete: false, + }); + } + }); }); describe("defaultOptions", () => {