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

[Tavern][bugfix] Fixed issue with transactional client #106

Merged
merged 1 commit into from
Feb 12, 2023
Merged

Conversation

KCarretto
Copy link
Collaborator

What type of PR is this?

/kind bugfix

What this PR does / why we need it:

Updates two of our mutations (claimTasks and createJob) to reload ents that were created/updated with the transactional client before returning them. This is because when the transactional client is used to commit the transaction, it can no longer be used to load ents. For regular usage this was fine, but the bug was encountered when attempting to traverse edges on the result (see the example mutation below). This is because the returned ent(s) would have embedded the transactional *ent.Client, because that's the client they were loaded with. Further queries using that client would error, meaning additional graph traversals would fail like the example below:

mutation BugExample($sessionIDs: [ID!]!, $input: CreateJobInput!) {
    createJob(sessionIDs: $sessionIDs, input: $input) {
         id
        tasks {
            id
        }
    }
}

This produces a GraphQL error "sql: transaction has already been committed or rolled back".

Our test cases were updated to reflect the more complex queries that real world users may have to prevent regression.

@KCarretto KCarretto added the bug Something isn't working label Feb 12, 2023
@KCarretto KCarretto requested a review from hulto February 12, 2023 01:59
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

LGTM

@hulto hulto merged commit a8b9cac into main Feb 12, 2023
@hulto hulto deleted the transaction-fix branch February 12, 2023 02:11
KCarretto added a commit that referenced this pull request Feb 1, 2024
 
fixed bug with transactional client (#106)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants