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

Update js-clients to process action responses #703

Merged
merged 2 commits into from
Dec 4, 2024
Merged

Conversation

garymardell
Copy link
Collaborator

The response from an upsert action was not being properly handled by useAction and therefore the data was not being returned to the user. This was because the action.hasReturnType looks like:

{
  "... on CreatePostResult": { hasReturnType: false },
  "... on UpdatePostResult": { hasReturnType: true },
}

in the useAction processResult it would just check if action.hasReturnType is truthy and if so use mutationData.result. However in this case the value is truthy but an object not a boolean value.

We already have the utility inside the api-client-core to process the action results (which is used both by the core action runner and background actions) which handles this case correctly so this updates the code to use that instead.

PR Checklist

  • Important or complicated code is tested
  • Any user facing changes are documented in the Gadget-side changelog
  • Any immediate changes are slated for release in Gadget via a generated package dependency bump
  • Versions within this monorepo are matching and there's a valid upgrade path

@garymardell
Copy link
Collaborator Author

The vite tests fail on this PR too as its trying to use the version of api-client-core that would be released by this PR...

@garymardell garymardell requested a review from airhorns December 2, 2024 22:46
@airhorns
Copy link
Contributor

airhorns commented Dec 3, 2024

Hm, thats new! If you don't bump the version in this PR, does it work ok?

Copy link
Contributor

@airhorns airhorns left a comment

Choose a reason for hiding this comment

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

Changes look good to me

@garymardell
Copy link
Collaborator Author

If you don't bump the version in this PR, does it work ok?

No, because the package doesn't export the function for react client to use without version bump. Going to merge a PR that exposes the function and bumps version first and then will rebase this.

@garymardell garymardell merged commit 9f48378 into main Dec 4, 2024
9 checks passed
@garymardell garymardell deleted the upsert-response branch December 4, 2024 22:53
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.

2 participants