Skip to content

feat: add batch mode query endpoint#7

Merged
dragonee merged 1 commit into
mainfrom
feat/batch-query-endpoint
Jul 5, 2026
Merged

feat: add batch mode query endpoint#7
dragonee merged 1 commit into
mainfrom
feat/batch-query-endpoint

Conversation

@dragonee

@dragonee dragonee commented Jul 5, 2026

Copy link
Copy Markdown
Member

Context

The only lookup endpoint today is GET /api/whose-name/query, which resolves exactly one {u, s, q} triple per request. Clients that need to reconcile many identities at once (e.g. a whole Slack channel against Jira) had to fire one HTTP request per lookup.

This adds a batch endpoint that accepts many queries in a single authenticated request, reusing the existing domain, Sanctum auth, and the per-request YamlFileRepository cache — so a batch costs ~one file read regardless of size.

API contract

POST /api/whose-name/query/batch (inside the existing auth:sanctum + ability:whose-name group)

Request

{"queries": [{"u":"test@example.org","s":"jira","q":"slack"}, ...]}

Response — a lean, index-correlated array in request order (null = no match):

[{"username":"U123456"},{"username":null}]

Status codes

  • 200 OK — every query resolved to a username
  • 207 Multi-Status — at least one query returned null (partial/total misses)
  • 422 Unprocessable Entity — malformed body (strict validation: 1–100 items, each u/s/q required|string)

Changes

  • DomainQueryService::whatAreTheNamesOf() loops the existing whatIsTheNameOf(), keeping iteration/ordering in the domain layer (framework stays a client of the domain).
  • Route — thin closure mapping u/s/q → domain and selecting 200/207.
  • Tests — domain (Mockery) tests for order/partial-null/empty; application feature tests for 200/207/422.
  • Docs — README "Batch query" section + an ADL recording the 207-vs-404 and lean-array decisions.

No DB/migration/binding changes; repository and interface untouched.

Verification

  • ./vendor/bin/sail test --without-tty24 passed, 1 pre-existing skip; all new domain and endpoint tests green.
  • Live curl against the booted app with a real Sanctum token confirmed 207 (mixed), 200 (all resolved), and 422 (malformed).

🤖 Generated with Claude Code

Add POST /api/whose-name/query/batch to resolve many {u,s,q} triples in a
single authenticated request, reusing the existing domain, Sanctum auth, and
per-request YAML cache (a batch costs ~one file read regardless of size).

- Domain: QueryService::whatAreTheNamesOf() loops whatIsTheNameOf(), keeping
  iteration/ordering in the domain layer.
- Response: lean, index-correlated array of {"username": ...} matching request
  order; null means no match.
- Status: 200 when all resolve, 207 Multi-Status when any item is null, 422 on
  malformed input (strict validation: 1-100 items, each u/s/q required).
- Tests: domain (Mockery) + application (feature) coverage for 200/207/422.
- Docs: README "Batch query" section and an ADL for the status/shape decision.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dragonee dragonee merged commit f5e9e1c into main Jul 5, 2026
1 check passed
@dragonee dragonee deleted the feat/batch-query-endpoint branch July 5, 2026 22:52
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