Skip to content

Instantly share code, notes, and snippets.

@ziedHamdi
Last active October 4, 2021 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziedHamdi/2c60bdd96ed3ccc4a7bd1146e02cea05 to your computer and use it in GitHub Desktop.
Save ziedHamdi/2c60bdd96ed3ccc4a7bd1146e02cea05 to your computer and use it in GitHub Desktop.
implementation of getServerSideProps in pages/xyz.js files
export async function getServerSideProps(context) {
const session = await getSession(context)
const client = initializeApollo({})
//await getDataFromTree(Index) replaced by manual client.query calls
const cpl = await client.query({
query: ComplaintsQuery, context: {
headers: {'infra-token': session?.infraToken}
}
})
//...
return {props: {session, ...(documentProps.props), fullUrl}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment