diff --git a/ui/src/graphql/ApolloProvider.tsx b/ui/src/graphql/ApolloProvider.tsx index b2e04080a..9bfbddb6c 100644 --- a/ui/src/graphql/ApolloProvider.tsx +++ b/ui/src/graphql/ApolloProvider.tsx @@ -2,7 +2,13 @@ import { ApolloProvider as Provider } from '@apollo/client'; import { FC } from 'react'; import { createGraphqlClient } from './client'; +let graphqlClient: ReturnType | null = null; + export const ApolloProvider: FC = ({ children }) => { - const graphqlClient = createGraphqlClient(); + // Initialize client only once, so we get only one cache instance. + if (!graphqlClient) { + graphqlClient = createGraphqlClient(); + } + return {children}; };