Redirect post query on relay-nextjs v2
julioxavierr opened this issue ยท 4 comments
Hi everyone,
I'm migrating from relay-nextjs v1 to v2, following the example migration. Everything seems to be working as expected and the new set up process is much simpler.
However, in my app there are some pages where the user is conditionally redirected based on data - that is, depending on some user info in the database, they are redirected to another page. Previously, we used serverSidePostQuery
to do this:
export default withRelay(Report, ReportQuery, {
serverSidePostQuery: (result, context) => {
if (!viewerCanSee(result.data)) {
context.res?.writeHead(302, { Location: "/dashboard" });
context.res?.end();
}
},
});
With the upgrade to v2, this callback has been removed. I'd like to understand more about what the recommended strategy is for this use case. I'm also interested in contributing if necessary.
Thanks for your help.
Seems like I'm going to have the same kind of problem when upgrading. We're using serverSidePostQuery
to set HTTP 404 status when the requested entity isn't found. Haven't really looked into alternative ways to do it with 2.0 yet.
E: Lol forgot I was the one who added serverSidePostQuery
in the first place ๐ #74 So I'll probably look into some way to make the same thing with v2 unless one already exist, but I'm not sure yet when we're going to upgrade. Could be a while.
This was an unintended removal, I'll make sure it's fixed soon!
This should be fixed in v2.0.1. Apologies for the breakage and thank you for opening this issue! Please re-open this issue if you continue to experience issues with this API or fetchPolicy
.
@rrdelaney wow, that was fast! Thank you!