fix: Correct GraphQL mutation format for Transactions.Delete()#17
Merged
eshaffer321 merged 3 commits intomainfrom Oct 26, 2025
Merged
fix: Correct GraphQL mutation format for Transactions.Delete()#17eshaffer321 merged 3 commits intomainfrom
eshaffer321 merged 3 commits intomainfrom
Conversation
The Delete method was using an incorrect GraphQL mutation format that
caused BAD_REQUEST errors when attempting to delete transactions.
Changes:
- Updated delete.graphql mutation to use DeleteTransactionMutationInput
with input wrapper (matching Python client and Monarch API format)
- Changed variables from {"id": "..."} to {"input": {"transactionId": "..."}}
- Added comprehensive test coverage for Delete method (success & error cases)
- Added examples/transaction_deletion.go with workarounds and real-world
use cases (including Walmart multi-delivery consolidation)
- Updated CHANGELOG.md with fix details and hideFromReports alternative
Before: deleteTransaction(id: $id) with {"id": "txn-123"}
After: deleteTransaction(input: $input) with {"input": {"transactionId": "txn-123"}}
Tests: All 54 tests pass
Fixes: BAD_REQUEST error when deleting transactions
- Move examples/transaction_deletion.go to examples/transaction_deletion/main.go to avoid main() conflicts - Fix NewClient() usage to match correct API (returns client and error) - Resolves lint and test failures in CI
Line 35 was redeclaring err instead of reusing the existing variable from line 14
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (44.55%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #17 +/- ##
==========================================
+ Coverage 43.18% 44.55% +1.36%
==========================================
Files 15 15
Lines 2239 1663 -576
==========================================
- Hits 967 741 -226
+ Misses 1198 846 -352
- Partials 74 76 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 14 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
Transactions.Delete()method which was returningBAD_REQUESTerrors due to incorrect GraphQL mutation format. The mutation now matches the Python client and Monarch API expectations.Root Cause
The Go client was using:
With variables:
{"id": "txn-123"}But the Monarch API expects (matching Python client):
With variables:
{"input": {"transactionId": "txn-123"}}Changes
internal/graphql/queries/transactions/delete.graphqlpkg/monarch/transactions.goto use input wrapper formatTestTransactionService_Delete,TestTransactionService_Delete_Error)examples/transaction_deletion.gowith:hideFromReportsworkaround for bank-imported transactionsCHANGELOG.mdwith fix detailsgo.mod/go.sumdependenciesTest Results
All tests pass ✅ (54 tests, 1 skipped):
Breaking Changes
None - this is a bug fix that makes the existing API work as intended.
Additional Notes
The error handling already captures both
CodeandMessagefrom the API response, so detailed error messages will now be visible when deletion fails (e.g., for bank-imported transactions that cannot be deleted).For transactions that cannot be deleted, users can use the
HideFromReportsfield as an alternative (documented in the new example file).Related Issues
Resolves issue where bank-imported transactions couldn't be deleted in Walmart multi-delivery consolidation tool.