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

Use mutation #855

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Use mutation #855

wants to merge 3 commits into from

Conversation

kmcginnes
Copy link
Collaborator

@kmcginnes kmcginnes commented Mar 28, 2025

Description

Switches away from useQuery() as the mechanism of executing the user provided query. Instead it uses useMutation().

This is to prevent unintended executions of the query. useQuery is designed to be executed when React renders the view. But that is not desired in this case. Especially if the user happens to be running an actual Gremlin mutation query. That could lead to multiple nodes created/modified/deleted.

The mutation version only executes when called. This means if the view is unmounted and remounted, then the query results are lost. The user must re-run the query explicitly. While I'm sure I could find a way to somehow persist these results in a way that makes sense, there's not a simple solution. So I'm kicking the can down the road to a future where that functionality is asked for explicitly.

As a result of this change, I can no longer reuse SearchResultList component. So I duplicated and modified that view for the raw query mutation. This removes the cancel button (which didn't work) and customizes the loading and error messages to be more appropriate for the context.

Validation

  • Tested with Neptune verifying that the query only executes when the form is submitted.

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0
    license.
  • I have run pnpm checks to ensure code compiles and meets standards.
  • I have run pnpm test to check if all tests are passing.
  • I have covered new added functionality with unit tests if necessary.
  • I have added an entry in the Changelog.md.

@kmcginnes kmcginnes marked this pull request as ready for review March 28, 2025 22:34
@kmcginnes kmcginnes marked this pull request as draft April 8, 2025 14:29
@kmcginnes
Copy link
Collaborator Author

Holding off on this PR until after the release

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.

Prevent multiple execution of mutation queries
1 participant