From 647da6b0193a5ebfa3abb8fe960f65eaef33dede Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Tue, 3 Sep 2024 12:06:24 -0400 Subject: [PATCH 1/2] Turn off structural sharing for bigint queries Signed-off-by: Steve Ayers --- .../src/use-infinite-query.test.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/connect-query/src/use-infinite-query.test.ts b/packages/connect-query/src/use-infinite-query.test.ts index e8fd9f0a..c45ffecd 100644 --- a/packages/connect-query/src/use-infinite-query.test.ts +++ b/packages/connect-query/src/use-infinite-query.test.ts @@ -39,6 +39,16 @@ const methodDescriptor = { }, }; +const defaultCallOptions = { + // This query returns a ListResponse which contains a bigint. + // As a result, tanstack will show an error that + // StructuralSharing requires data to be JSON serializable. + // So we turn it off for this test. Another option would be to + // implement a `select` option to transform the data into something + // JSON serializable. + structuralSharing: false, +}; + const mockedPaginatedTransport = mockPaginatedTransport(); describe("useInfiniteQuery", () => { @@ -51,6 +61,7 @@ describe("useInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }, @@ -102,6 +113,7 @@ describe("useInfiniteQuery", () => { const { result } = renderHook( () => { return useInfiniteQuery(methodDescriptor, disableQuery, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }); @@ -121,6 +133,7 @@ describe("useInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", transport: mockPaginatedTransport({ @@ -153,6 +166,7 @@ describe("useInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", transport: mockPaginatedTransport(undefined, true), @@ -192,6 +206,7 @@ describe("useInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }, @@ -226,6 +241,7 @@ describe("useInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }, @@ -270,6 +286,7 @@ describe("useInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }, @@ -300,6 +317,7 @@ describe("useSuspenseInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }, @@ -356,6 +374,7 @@ describe("useSuspenseInfiniteQuery", () => { page: 0n, }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", enabled: false, @@ -387,6 +406,7 @@ describe("useSuspenseInfiniteQuery", () => { extraField: "extra", }, { + ...defaultCallOptions, getNextPageParam: (lastPage) => lastPage.page + 1n, pageParamKey: "page", }, From 2f12c77a5dbefd46ab048e323954b30b0473ca5d Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Tue, 3 Sep 2024 12:07:14 -0400 Subject: [PATCH 2/2] Docs Signed-off-by: Steve Ayers --- packages/connect-query/src/use-infinite-query.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/connect-query/src/use-infinite-query.test.ts b/packages/connect-query/src/use-infinite-query.test.ts index c45ffecd..ccdc45c5 100644 --- a/packages/connect-query/src/use-infinite-query.test.ts +++ b/packages/connect-query/src/use-infinite-query.test.ts @@ -43,8 +43,8 @@ const defaultCallOptions = { // This query returns a ListResponse which contains a bigint. // As a result, tanstack will show an error that // StructuralSharing requires data to be JSON serializable. - // So we turn it off for this test. Another option would be to - // implement a `select` option to transform the data into something + // So we turn it off for these test. Another option would be to + // implement a `select` option to transform the response into something // JSON serializable. structuralSharing: false, };