Skip to content

Conversation

@wcole1-godaddy
Copy link
Contributor

Changes

This PR improves authentication handling and type safety across all godaddy hooks in the React package.

Key Improvements

  • Fixed JWT-only auth flows: Removed blocking early returns that prevented JWT-only authentication from working
  • Enhanced type safety: Added explicit type generics to all useMutation calls for better type inference
  • Simplified auth pattern: Refactored to match the godaddy.ts overload structure using direct ternaries
  • Cleaner code: Removed unnecessary wrapper functions for better readability
  • Better error handling: Let React Query handle error throwing automatically instead of manual error management

Files Changed (22)

  • All hook files in packages/react/src/components/checkout/
  • packages/react/src/lib/godaddy/godaddy.ts
  • packages/react/src/lib/graphql-with-errors.ts
  • packages/react/src/server.ts
  • Example files in examples/nextjs/
  • Deleted obsolete packages/react/src/lib/godaddy/server.ts

Testing

  • Type checking passes
  • Maintains backward compatibility with existing session-based auth
  • Enables new JWT-only authentication flows

Related

This refactor ensures consistent authentication patterns across the entire checkout component library.

wcole1-godaddy and others added 2 commits November 4, 2025 11:02
- Remove blocking early returns that prevented JWT-only auth flows
- Add explicit type generics to all useMutation calls
- Simplify auth pattern to match godaddy.ts overload structure
- Use direct ternary for jwt vs session auth selection
- Remove unnecessary wrapper functions for cleaner code
- Let React Query handle error throwing automatically

Amp-Thread-ID: https://ampcode.com/threads/T-2469796c-8d8e-4450-be09-b8dfe01f101a
Co-authored-by: Amp <amp@ampcode.com>
@wcole1-godaddy wcole1-godaddy requested a review from a team as a code owner November 4, 2025 17:58
@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

🦋 Changeset detected

Latest commit: 975459a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@godaddy/react Patch
nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

wcole1-godaddy and others added 21 commits November 4, 2025 13:25
- Convert double quotes to single quotes
- Standardize indentation (2 spaces)
- Apply formatting across React components and utilities

Amp-Thread-ID: https://ampcode.com/threads/T-1d878f81-bcc4-4acd-a1d8-11f31b88ecee
Co-authored-by: Amp <amp@ampcode.com>
- Return early after clearing mismatched JWT to avoid race condition
- Check for missing JWT before cancelled flag to ensure failure is captured
- Guard exchangeFailed state updates with cancelled check to prevent updates after unmount

Amp-Thread-ID: https://ampcode.com/threads/T-77963656-ab13-4782-b5fb-efcf2be4696a
Co-authored-by: Amp <amp@ampcode.com>
Copy link
Contributor

@pbennett1-godaddy pbennett1-godaddy left a comment

Choose a reason for hiding this comment

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

tested and everything working on my side for regression

@wcole1-godaddy wcole1-godaddy merged commit 811bb55 into main Nov 10, 2025
3 checks passed
@wcole1-godaddy wcole1-godaddy deleted the auth-updates branch November 10, 2025 22:26
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.

3 participants