Skip to content

fix: error handling and loading states in with-apollo-and-redux example#91457

Merged
icyJoseph merged 9 commits into
vercel:canaryfrom
ZaforAbdullah:fix/with-apollo-and-redux-error-handling
Jul 21, 2026
Merged

fix: error handling and loading states in with-apollo-and-redux example#91457
icyJoseph merged 9 commits into
vercel:canaryfrom
ZaforAbdullah:fix/with-apollo-and-redux-error-handling

Conversation

@ZaforAbdullah

@ZaforAbdullah ZaforAbdullah commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

For Contributors

Fixing a bug

  • Fixes #(open or reference an issue if one exists, otherwise omit)
  • No tests required — this is an examples/ change only
  • No custom error links needed — failures are surfaced via Apollo's built-in error state

Summary

  • PostList destructured data before checking loading/error, so the component threw when data was undefined (e.g., on the initial fetch or after a query error) instead of showing the loading/error UI.
  • Move the error/loading/!data guard clauses above the data destructuring and loadMorePosts definition, and add a !data check so the component never accesses properties on an undefined value.
  • Bump graphql (14.5.816.13.1) and lodash (4.17.204.17.23) in the example's package.json to pick up fixes in dependencies the example relies on.

Note:

Initially this PR suppose to target upstream DB issue

@nextjs-bot nextjs-bot added the examples Issue was opened via the examples template. label Mar 16, 2026
@nextjs-bot

nextjs-bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Allow CI Workflow Run

  • approve CI run for commit: 47bb590

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

await apolloClient.query({
query: ALL_POSTS_QUERY,
variables: allPostsQueryVars,
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you'd want to error at build time, not hide the error or hope to catch it during rendering. You might end up shipping bad UI

@ZaforAbdullah ZaforAbdullah Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It call https://nextjs-graphql-with-prisma-simple-foo.vercel.app/api endpoint which is empty, hence the example project can't be build at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm but that's another issue then, that project should serve data... I don't have time to look into at the moment - but I'll try later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I asked them about it, they'll look into it. 🙏

@icyJoseph icyJoseph Mar 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I think, examples/with-apollo-and-redux/components/PostList.js is a good change, but not this one, nor the one below, subject to the API being fixed - let's wait a bit for an answer from Prisma Labs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@icyJoseph Any update from Prisma Labs? Is it possible tag someone in this PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No updates yes, they have it on their radar though.

@ZaforAbdullah ZaforAbdullah Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Removed try...catch blocks

Analysis: The demo backend (nextjs-graphql-with-prisma-simple-foo.vercel.app) returns HTTP 500 because its DB table may no longer exists — the database was never migrated or has been wiped. The GraphQL server itself is running, but any query that touches the database fails.

Note: with this change build (npm run dev) will be failed in runtime

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@icyJoseph

Any update from Prisma Labs? BTW I don't think so they managing those repos now

Comment thread examples/with-apollo-and-redux/components/PostList.js
Comment thread examples/with-apollo-and-redux/package.json Outdated
@ZaforAbdullah ZaforAbdullah changed the title fix(with-apollo-and-redux): resolve install failure and handle upstream API errors fix (with-apollo-and-redux): resolve install failure and handle upstream API errors Apr 18, 2026
@icyJoseph

Copy link
Copy Markdown
Member

On its current state, this will show the error path right? Rather than crashing out.

@ZaforAbdullah

Copy link
Copy Markdown
Contributor Author

On its current state, this will show the error path right? Rather than crashing out.

Current state: Removed try...catch blocks

@icyJoseph

1) Removed try...catch blocks
It crashed
image

2) Added try...catch blocks
It able to run // Note: I'm not adding any screenshot for it

@icyJoseph

Copy link
Copy Markdown
Member

Ah there's one more thing blocking this merge. Not that, it'll work anyway, because the DB upstream is still down.

We require verified commit signatures.

There's a couple of unsigned commits:

@ZaforAbdullah
ZaforAbdullah force-pushed the fix/with-apollo-and-redux-error-handling branch from 8ee51bc to bcd2666 Compare July 20, 2026 09:33
@ZaforAbdullah

Copy link
Copy Markdown
Contributor Author

Ah there's one more thing blocking this merge. Not that, it'll work anyway, because the DB upstream is still down.

We require verified commit signatures.

There's a couple of unsigned commits:

Ah there's one more thing blocking this merge. Not that, it'll work anyway, because the DB upstream is still down.

We require verified commit signatures.

There's a couple of unsigned commits:

Please check @icyJoseph

@icyJoseph

Copy link
Copy Markdown
Member

Btw, sorry this took so long, I am a bit surprised we didn't get any resolution on the upstream DB.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 12e70b2

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Stats skipped

Commit: 12e70b2
View workflow run

@icyJoseph

Copy link
Copy Markdown
Member

There's a minor lint issue:

[warn] examples/with-apollo-and-redux/package.json
[warn] Code style issues found in the above file. Run Prettier with --write to fix.

@icyJoseph

Copy link
Copy Markdown
Member

Nice, just to be orderly, can you update the PR description with what's actually been done?

@ZaforAbdullah ZaforAbdullah changed the title fix (with-apollo-and-redux): resolve install failure and handle upstream API errors fix (with-apollo-and-redux): error handling and loading states in with-apollo-and-redux example Jul 21, 2026
@ZaforAbdullah

Copy link
Copy Markdown
Contributor Author

Nice, just to be orderly, can you update the PR description with what's actually been done?

I have updated it @icyJoseph

@ZaforAbdullah ZaforAbdullah changed the title fix (with-apollo-and-redux): error handling and loading states in with-apollo-and-redux example fix: error handling and loading states in with-apollo-and-redux example Jul 21, 2026
@icyJoseph
icyJoseph merged commit 93c59f0 into vercel:canary Jul 21, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Issue was opened via the examples template.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants