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

Create a system for declarative mutations for forms and buttons #341

Open
Tracked by #342
lemonmade opened this issue Sep 17, 2024 · 0 comments
Open
Tracked by #342

Create a system for declarative mutations for forms and buttons #341

lemonmade opened this issue Sep 17, 2024 · 0 comments

Comments

@lemonmade
Copy link
Owner

lemonmade commented Sep 17, 2024

https://chatgpt.com/share/66e912b5-17c4-8000-b123-f24c062b60ea

<ui-graphql-operation>
  mutation UpdateEpisodeRating($episodeId: ID!, $rating: Int!) {
    updateEpisodeRating(episodeId: $episodeId, rating: $rating) {
      id
      rating
    }
  }
</ui-graphql-operation>

<ui-form 
  action="mutate(UpdateEpisodeRating)" 
  success-action="navigate(/episodes/123)" 
  error-action="toast">

  <!-- Field names become mutation input -->
  <ui-number-field name="rating" value="5"></ui-number-field>

  <ui-button action="submit">Submit</ui-button>
</ui-form>
<ui-graphql-operation>
  mutation UpdateEpisodeRating($rating: Int!) {
    updateEpisodeRating(rating: $rating) {
      id
      rating
    }
  }
</ui-graphql-operation>

<ui-button 
  action="mutate(UpdateEpisodeRating)" 
  success-action="auto" 
  <!-- or... -->
  success-action="navigate(/episodes/123)" 
  error-action="auto" 
  <!-- or... -->
  error-action="toast">
  Update Rating
</ui-button>
  • Can also reference a mutation referenced in the extension TOML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant