Skip to content

Commit

Permalink
feat: adds graphql ssr data
Browse files Browse the repository at this point in the history
  • Loading branch information
AssisrMatheus committed Nov 1, 2021
1 parent d040049 commit 4f51dec
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pages/project/[slug]/planner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ type PlannerParams = {
slug: string;
};

type PlannerServerSideProps = PlannerParams;
type PlannerServerSideProps = PlannerParams & {
// Graphql data
data: PlannerQuery;
};

type PlannerContainerProps = InferGetServerSidePropsType<typeof getServerSideProps>;

const PlannerContainer: NextPage<PlannerContainerProps> = ({ slug }) => {
const PlannerContainer: NextPage<PlannerContainerProps> = ({ slug, data: ssrData }) => {
// ***********
// ** Grapqhl declarations
// ***********
Expand Down Expand Up @@ -53,7 +57,7 @@ const PlannerContainer: NextPage<PlannerContainerProps> = ({ slug }) => {
}
}, [refetch]);

return <PlannerTemplate data={data} loading={loading} error={error} handleTryAgain={handleTryAgain} />;
return <PlannerTemplate data={data || ssrData} loading={loading} error={error} handleTryAgain={handleTryAgain} />;
};

export const getServerSideProps: GetServerSideProps<WithApolloProps<PlannerServerSideProps>, PlannerParams> = async ({
Expand Down Expand Up @@ -89,7 +93,8 @@ export const getServerSideProps: GetServerSideProps<WithApolloProps<PlannerServe

return addApolloState(apolloClient, {
props: {
slug
slug,
data
}
});
};
Expand Down

0 comments on commit 4f51dec

Please sign in to comment.