From 0382e8429d275422f7da2c2a98e4a61c54f8366f Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 7 Jul 2022 18:56:16 +0300 Subject: [PATCH] pages/index: constant GetOwnerData query --- pages/index.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 9ed387e..8a13420 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -72,6 +72,19 @@ function Home({ data }: PageProps) { type PageProps = BasePageProps & { data: GetOwnerData }; +const QUERY_GET_OWNER_DATA = gql` + query GetOwnerData($domainname: String) { + leads(owner_domainname: $domainname) { + fullname + leadid + } + opportunities(owner_domainname: $domainname) { + name + opportunityid + } + } +`; + export const getServerSideProps: GetServerSideProps = async (ctx) => { const user = await fetchUser({ headers: ctx?.req?.headers?.cookie @@ -84,18 +97,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => const apolloClient = initializeApollo(); const { data: ownerData } = await apolloClient.query({ - query: gql` - query GetOwnerData($domainname: String) { - leads(owner_domainname: $domainname) { - fullname - leadid - } - opportunities(owner_domainname: $domainname) { - name - opportunityid - } - } - `, + query: QUERY_GET_OWNER_DATA, variables: { domainname: getDomainName(user), },