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

SQL Transaction Management #411

Open
ahobsonsayers opened this issue Jan 16, 2023 · 7 comments
Open

SQL Transaction Management #411

ahobsonsayers opened this issue Jan 16, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@ahobsonsayers
Copy link

ahobsonsayers commented Jan 16, 2023

What would you like to be added:

I would be great if GraphJin had support for managing (opening/committing) SQL transactions. This feature would allow multiple queries and mutations to be executed in series and then committed or rolled back atomically as desired.

There is currently a (highly upvoted) issue open in Hasura for a similar feature (See hasura/graphql-engine#5773), including a PR with an implementation using websockets (See hasura/graphql-engine#3557).

Having this feature in GraphJin would be amazing and i feel would help tackle a lot of use cases that GraphJin cannot currently solve (see example below). Do you think implementing this feature is possible? If so, is it something that might be on your roadmap? If you feel it implementing something is feasible, I might be able to find some time to contribute.

Why is this needed:

I have been using GraphJin for some pretty simple queries and mutations (and its great!), however as I progress with my project, I have noticed that i have wanted to do some more complex operations which I would need transaction control for:
e.g.

  • Insert a new row to Table A
  • If the number of rows in Table A satisfying a where clause is larger than a number found in Table B
  • Insert a row in a Table C

Currently, while the above could be done with GraphJin and series of queries/mutations, it would not take place within a transaction, and I want all of the above to be atomic.

The alternative to achieve the above atomically is, instead of using GraphJin, use a database trigger. This is i how i have currently been getting around this problem, but database triggers are difficult to track and maintain, especially as i add increasing numbers to do the things i need to.

Ideally, id like this sort of logic to be in my code rather than in the database, so having transaction control would be invaluable.

@ahobsonsayers ahobsonsayers added the enhancement New feature or request label Jan 16, 2023
@dosco
Copy link
Owner

dosco commented Jan 17, 2023

To double confirm you are asking about transaction support for the APIs exposed in the core package correct and not the standalone service?

@dosco
Copy link
Owner

dosco commented Jan 17, 2023

Added support for transactions. Let me know if this works for you I still have to expose these APIs in the NodeJS package will do that next. c7ed332

@dosco
Copy link
Owner

dosco commented Jan 17, 2023

Also thanks for the detailed issue I like the feature roadmap to be about what people want and need so insights like this one really help me fill gaps I might have missed.

@dosco
Copy link
Owner

dosco commented Jan 23, 2023

@ahobsonsayers let me know if this worked for you?

@ahobsonsayers
Copy link
Author

ahobsonsayers commented Jan 24, 2023

Hey @dosco! This is amazing, i had barely opened this issue and you managed to implement my request! I'm gonna give this a try out over the next day or so and will let you know if this solves what i was trying to do. Thanks so much again for being so prompt!

@dosco
Copy link
Owner

dosco commented Jan 25, 2023

please try with the new graphjin v3 that was released today

@dosco
Copy link
Owner

dosco commented Feb 4, 2023

@ahobsonsayers can i close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants