Skip to content

fix: Remove unsupported WithMerchant filter from transaction queries#18

Merged
eshaffer321 merged 1 commit intomainfrom
fix/remove-unsupported-merchant-filter
Nov 27, 2025
Merged

fix: Remove unsupported WithMerchant filter from transaction queries#18
eshaffer321 merged 1 commit intomainfrom
fix/remove-unsupported-merchant-filter

Conversation

@eshaffer321
Copy link
Copy Markdown
Owner

Summary

Removes the WithMerchant() filter method from transaction queries because the MonarchMoney GraphQL API does not support filtering by merchant name. Using this filter causes a 400 BAD_REQUEST error.

  • Removed: WithMerchant() method from TransactionQueryBuilder interface and implementation
  • Alternative: Users should use Search() method instead, which searches merchants and other text fields
  • 📚 Reference: Aligned with Python client implementation which doesn't expose a merchant filter

Problem

The TransactionFilterInput GraphQL type does not include a merchant field. Attempting to use WithMerchant() results in:

Field 'merchant' is not defined by type 'TransactionFilterInput'

According to the Python reference implementation, the supported filters are:

  • search, categories, accounts, tags
  • hasAttachments, hasNotes, hideFromReports
  • isRecurring, isSplit, importedFromMint, syncedFromInstitution
  • startDate, endDate

Solution

Before:

transactions, err := client.Transactions.Query().
    WithMerchant("Starbucks").
    Execute(ctx)

After:

transactions, err := client.Transactions.Query().
    Search("Starbucks").  // Searches across merchant names and other text fields
    Execute(ctx)

Changes

  • pkg/monarch/interfaces.go: Removed WithMerchant() from interface
  • pkg/monarch/transactions.go: Removed implementation, enhanced Search() documentation

Test Plan

  • All existing tests pass (54 tests)
  • Verified alignment with Python client's supported filters
  • Confirmed Search() provides equivalent functionality

Breaking Change

⚠️ This is a breaking change for anyone using WithMerchant(). However:

  1. The method never worked correctly (returns API errors)
  2. Migration is simple: replace with Search()
  3. Functionality is preserved via Search() method

The MonarchMoney GraphQL API does not support filtering transactions
by merchant name via the `merchant` field in TransactionFilterInput.
Attempting to use this filter results in a 400 BAD_REQUEST error:

  Field 'merchant' is not defined by type 'TransactionFilterInput'

This fix removes the WithMerchant() method from the TransactionQueryBuilder
interface and implementation. Users should use the Search() method instead,
which searches across multiple text fields including merchant names.

Changes:
- Removed WithMerchant() from TransactionQueryBuilder interface
- Removed WithMerchant() implementation from transactionQueryBuilder
- Enhanced Search() method documentation to clarify it searches merchants

Migration:
Before: client.Transactions.Query().WithMerchant("Starbucks")
After:  client.Transactions.Query().Search("Starbucks")

This aligns the Go client with the Python reference implementation,
which does not expose a merchant-specific filter parameter.
@eshaffer321 eshaffer321 merged commit d5a0356 into main Nov 27, 2025
11 checks passed
@eshaffer321 eshaffer321 deleted the fix/remove-unsupported-merchant-filter branch November 27, 2025 03:17
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.82%. Comparing base (eba9f02) to head (e54c9ec).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (44.82%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
+ Coverage   44.74%   44.82%   +0.08%     
==========================================
  Files          15       15              
  Lines        1665     1662       -3     
==========================================
  Hits          745      745              
+ Misses        845      842       -3     
  Partials       75       75              
Flag Coverage Δ
unittests 44.82% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/monarch/transactions.go 73.50% <ø> (+0.54%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eba9f02...e54c9ec. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant