RevereCRE / relay-nextjs

⚡️ Relay integration for Next.js apps
https://reverecre.github.io/relay-nextjs/
MIT License
251 stars 30 forks source link

Add serverSidePostQuery hook to access query data + NextContext during SSR #74

Closed FINDarkside closed 1 year ago

FINDarkside commented 1 year ago

Adds serverSidePostQuery function option to relay-nextjs which allows to access returned query data and NextContext after the query has finished during SSR. This allows to handle stuff like 404 status codes for non-existing pages. Related: #15

Example usage:

serverSidePostQuery: (queryResponse: any, ctx) => {
  if (!queryResponse?.data?.company && ctx.res) {
    ctx.res.statusCode = 404;
  }
},

Any feedback welcome.

FINDarkside commented 1 year ago

Added it to docs!

rrdelaney commented 1 year ago

This is now published in v0.10.0 🥳