GraphQL error occurred [getDataFromTree] TypeError when using getStaticProps

Hi, has anyone had GraphQL error occurred [getDataFromTree] TypeError: Cannot read property ‘Page’ of undefined or similar when using getStaticProps to get data with Apollo and Keystonejs? The data loads fine, but for the first split second it is undefined then shows this error in dev followed by the actual data.

This is the current code:

import { ApolloClient, ApolloLink } from '@apollo/client';
import { onError } from '@apollo/link-error';
import { getDataFromTree } from '@apollo/client/react/ssr';
import { createUploadLink } from 'apollo-upload-client';
import withApollo from 'next-with-apollo';
import { endpoint, prodEndpoint } from '../config';

function createClient({ headers }) {
  return new ApolloClient({
    link: ApolloLink.from([
      onError(({ graphQLErrors, networkError }) => {
        if (graphQLErrors)
          graphQLErrors.forEach(({ message, locations, path }) =>
            console.log(
              `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
            )
          );
        if (networkError)
          console.log(
            `[Network error]: ${networkError}. Backend is unreachable. Is it running?`
          );
      }),
      createUploadLink({
        uri: process.env.NODE_ENV === 'development' ? endpoint : prodEndpoint,
        fetchOptions: {
          credentials: 'include',
        },
        headers,
      }),
    ]),
  });
}

export default withApollo(createClient, { getDataFromTree });