diff --git a/src/react/ssr/__tests__/useLazyQuery.test.tsx b/src/react/ssr/__tests__/useLazyQuery.test.tsx
index 963f9726777..018122c67b8 100644
--- a/src/react/ssr/__tests__/useLazyQuery.test.tsx
+++ b/src/react/ssr/__tests__/useLazyQuery.test.tsx
@@ -31,6 +31,37 @@ describe('useLazyQuery Hook SSR', () => {
]
};
+ it('should not execute the query and properly render the component', () => {
+ const link = mockSingleLink({
+ request: { query: CAR_QUERY },
+ result: { data: CAR_RESULT_DATA }
+ });
+
+ const client = new ApolloClient({
+ cache: new InMemoryCache(),
+ link,
+ ssrMode: true
+ });
+
+ let isRendered = false;
+ const Component = () => {
+ useLazyQuery(CAR_QUERY);
+ isRendered = true;
+ return null;
+ };
+
+ const app = (
+
+
+
+ );
+
+ return renderToStringWithData(app).then(markup => {
+ expect(isRendered).toBeTruthy();
+ expect(markup).toEqual('');
+ });
+ });
+
it('should run query only after calling the lazy mode execute function', () => {
const link = mockSingleLink({
request: { query: CAR_QUERY },
diff --git a/src/react/ssr/__tests__/useQuery.test.tsx b/src/react/ssr/__tests__/useQuery.test.tsx
index 0e5aacb584b..3a1645fdb64 100644
--- a/src/react/ssr/__tests__/useQuery.test.tsx
+++ b/src/react/ssr/__tests__/useQuery.test.tsx
@@ -108,6 +108,41 @@ describe('useQuery Hook SSR', () => {
});
});
+ it('should skip SSR tree rendering if `fetchPolicy` option is `standby`', () => {
+ const link = mockSingleLink({
+ request: { query: CAR_QUERY },
+ result: { data: CAR_RESULT_DATA }
+ });
+
+ const client = new ApolloClient({
+ cache: new InMemoryCache(),
+ link,
+ ssrMode: true
+ });
+
+ let renderCount = 0;
+ const Component = () => {
+ const { data, loading } = useQuery(CAR_QUERY, { fetchPolicy:'standby' });
+ renderCount += 1;
+ if (!loading && data) {
+ const { make } = data.cars[0];
+ return
{make}
;
+ }
+ return null;
+ };
+
+ const app = (
+
+
+
+ );
+
+ return renderToStringWithData(app).then(result => {
+ expect(renderCount).toBe(1);
+ expect(result).toEqual('');
+ });
+ });
+
it('should skip both SSR tree rendering and SSR component rendering if `ssr` option is `false` and `ssrMode` is `true`',
async () => {
const link = mockSingleLink({