diff --git a/services/crm/graphql/client.js b/apollo/client.js similarity index 85% rename from services/crm/graphql/client.js rename to apollo/client.js index 2d86319..27b68e8 100644 --- a/services/crm/graphql/client.js +++ b/apollo/client.js @@ -1,5 +1,4 @@ import { ApolloClient, InMemoryCache } from '@apollo/client'; -import { useMemo } from 'react'; /** @type {import('@apollo/client').ApolloClient} */ let apolloClient; @@ -32,8 +31,3 @@ export function initializeApollo(initialState = null) { return _apolloClient; } - -export function useApollo(initialState) { - const client = useMemo(() => initializeApollo(initialState), [initialState]); - return client; -} diff --git a/apollo/hooks.js b/apollo/hooks.js new file mode 100644 index 0000000..b2d092c --- /dev/null +++ b/apollo/hooks.js @@ -0,0 +1,7 @@ +import { useMemo } from 'react'; +import { initializeApollo } from './client'; + +export function useApollo(initialState) { + const client = useMemo(() => initializeApollo(initialState), [initialState]); + return client; +} diff --git a/pages/_app.tsx b/pages/_app.tsx index 3806f71..23cd5d6 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,9 +1,9 @@ import { ApolloProvider } from '@apollo/client'; import 'antd/dist/antd.less'; +import { useApollo } from 'apollo/hooks'; import Layout from 'Components/Layout'; import type { AppProps } from 'next/app'; import Head from 'next/head'; -import { useApollo } from 'services/crm/graphql/client'; import { ThemeProvider } from 'styled-components'; import { GlobalStyle } from 'UIKit/colors'; import theme from 'UIKit/theme'; diff --git a/pages/index.tsx b/pages/index.tsx index 0d1d527..10c1033 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,6 @@ import { NormalizedCacheObject } from '@apollo/client'; +import { initializeApollo } from 'apollo/client'; import type { GetServerSideProps, NextPage } from 'next'; -import { initializeApollo } from 'services/crm/graphql/client'; import { fetchUser } from 'services/user'; import type { User } from 'services/user/types';