function getGetServerSideProps (
  { query: queryOrFunc, variables: varsOrFunc, notFound, authRequired }) {
  return async function ({ req, res, query: params }) {
    const { nodata, ...realParams } = params
    // we want to use client-side cache
    if (nodata) return { props: { } }

    const variables = typeof varsOrFunc === 'function' ? varsOrFunc(realParams) : varsOrFunc
    const vars = { ...realParams, ...variables }
    const query = typeof queryOrFunc === 'function' ? queryOrFunc(vars) : queryOrFunc

    const client = await getSSRApolloClient({ req, res })

    let { data: { me } } = await client.query({ query: ME })

    // required to redirect to /signup on page reload
    // if we switched to anon and authentication is required
    if (req.cookies[MULTI_AUTH_LIST] === MULTI_AUTH_ANON) {
      me = null
    }

    if (authRequired && !me) {
      let callback = process.env.NEXT_PUBLIC_URL + req.url
      // On client-side routing, the callback is a NextJS URL
      // so we need to remove the NextJS stuff.
      // Example: /_next/data/development/territory.json
      callback = callback.replace(/\/_next\/data\/\w+\//, '/').replace(/\.json$/, '')
      return {
        redirect: {
          destination: `/signup?callbackUrl=${encodeURIComponent(callback)}`
        }
      }
    }

    const { data: { price } } = await client.query({
      query: PRICE, variables: { fiatCurrency: me?.privates?.fiatCurrency }
    })

    const { data: { blockHeight } } = await client.query({
      query: BLOCK_HEIGHT, variables: {}
    })

    const { data: { chainFee } } = await client.query({
      query: CHAIN_FEE, variables: {}
    })

    let error = null; let data = null; let props = {}
    if (query) {
      try {
        ({ error, data } = await client.query({
          query,
          variables: vars
        }))
      } catch (e) {
        console.error(e)
      }

      if (error || !data || (notFound && notFound(data, vars, me))) {
        error && console.error(error)
        res.writeHead(302, {
          Location: '/404'
        }).end()
      }

      props = {
        apollo: {
          query: print(query),
          variables: vars
        }
      }
    }

    oneDayReferral(req, { me })

    return {
      props: {
        ...props,
        me,
        price,
        blockHeight,
        chainFee,
        ssrData: data
      }
    }
  }
}
Takes a query and variables and returns a getServerSideProps function

@param opts Options
@param opts.query graphql query or function that return graphql query
@param opts.variables graphql variables or function that return graphql variables
@param opts.notFound function that tests data to determine if 404
@param opts.authRequired boolean that determines if auth is required