fix: Implementing 404 page for unknown crags and climbs #947
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
name: Pull request
about: Create a pull request
title: Implementing 404 page for unknown crags and climbs
labels: ''
assignees: ''
What type of PR is this?(check all applicable)
Description
Related Issues
Addressing Issue #927
What this PR achieves
As pointed out in the issue, if you go to https://openbeta.io/crag/79be0b8 or https://openbeta.io/climbs/428f9f46-7dab, you are taken to a page that looks like this:
This is because we are trying to query the graphqlClient with an invalid UUID. This throws an unhandled GraphQLError error in getStaticProps functions of both the crag and climbs page.
What this PR achieves is that it handles this error by returning { notFound: true } in getStaticProps, which consequently leads to the 404 page.
Notes
I ensured that this error will only trigger when there is an invalid UUID. The idea being if there were other errors, there may be a different page. I wonder if this was the right approach or if a general catch-all would work.
This is actually my first pull request, so I would appreciate some strict scrutiny of my code.