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

Fix hydration error on access denied error pages #2212

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jnatten
Copy link
Contributor

@jnatten jnatten commented Nov 14, 2024

Fikser hydreringsfeil på resourcepage dersom vi finner en tilgangsfeil.

"Problemet" er at apollo ikke tar med feil i cachen sin så alle feil vil bare rendres på server dersom vi baserer oss på error objektet i queryen.

Denne PR'en fikser det ved å sende feil fra server til klient (og å hente det ut i useGraphQuery gjennom en context.

Eksempel hvis en læringssti er privat: http://localhost:3000/subject:20/topic:1:194565/resource:1:179189
Eksempel på en 410: http://localhost:3000/nb/article/9645

This allows us to have helper methods on the class.
This was fixed by using responseContext to determine whether or not to
render an `AccessDeniedError`.

This feels fairly fragile, but not sure how it can be improved as long
as errors aren't passed with the graphql cache from server to client.
Previously this would render differently on client and server due to the
if check only triggering if the `redirectContext` was present.
@jnatten jnatten requested a review from a team November 14, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant