Skip to content

feat: add include filter support to the GET /api/v3/proposals endpoint#2641

Open
jekabs-karklins wants to merge 2 commits intomasterfrom
SWAP-5421-implement-sample-info-retrieval
Open

feat: add include filter support to the GET /api/v3/proposals endpoint#2641
jekabs-karklins wants to merge 2 commits intomasterfrom
SWAP-5421-implement-sample-info-retrieval

Conversation

@jekabs-karklins
Copy link
Copy Markdown
Contributor

@jekabs-karklins jekabs-karklins commented Mar 30, 2026

Description

Add include filter support to the GET /api/v3/proposals endpoint, allowing callers to request associated samples inline within a single query.

Motivation

The proposals endpoint only supported simple find() queries with no relation expansion. We used to need to make separate requests to fetch samples belonging to a proposal. The dataset endpoint already supports this pattern via MongoDB aggregation $lookup stages - this change brings proposals to parity.

The following query now works

curl -X 'GET' \
  '<backend>/api/v3/proposals' \
  -H 'Authorization: Bearer <token>' \
  -H 'accept: application/json' \
  --data-urlencode 'filter={"where":{"proposalId":"123456"},"include":[{"relation":"samples"}]}'

Fixes

SWAP-5421

Changes:

  • Added src/proposals/types/proposal-lookup.ts — defines ProposalLookupKeysEnum and PROPOSAL_LOOKUP_FIELDS with a $lookup stage joining Sample on Sample.proposalId = Proposal.proposalId
  • Added src/proposals/interfaces/proposal-relations.interface.ts — IProposalFilters, IProposalRelation, IProposalScopes types mirroring the dataset filter interface pattern
  • Added findAllComplete(), addLookupFields(), and extractRelationsAndScopes() to ProposalsService — builds an aggregation pipeline with optional $lookup stages and applies scope-level where, fields, limits
  • Updated GET /proposals in ProposalsController — routes to findAllComplete() when include is present in the filter, otherwise falls back to existing findAll()
  • Updated IncludeValidationPipe — extended the strict union type to include ProposalLookupKeysEnum alongside the existing dataset and origdatablock enum types

Tests included

  • Included for each change/fix?
  • Passing?

@jekabs-karklins jekabs-karklins requested a review from a team as a code owner March 30, 2026 13:51
@jekabs-karklins jekabs-karklins changed the title feat: implement include sample info for proposal entity feat: add include filter support to the GET /api/v3/proposals endpoint Mar 30, 2026
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