Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect post query on relay-nextjs v2 #87

Closed
julioxavierr opened this issue May 23, 2023 · 4 comments
Closed

Redirect post query on relay-nextjs v2 #87

julioxavierr opened this issue May 23, 2023 · 4 comments

Comments

@julioxavierr
Copy link

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.

@FINDarkside
Copy link
Contributor

FINDarkside commented May 23, 2023

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.

@rrdelaney
Copy link
Contributor

This was an unintended removal, I'll make sure it's fixed soon!

@rrdelaney
Copy link
Contributor

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.

@julioxavierr
Copy link
Author

@rrdelaney wow, that was fast! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants