feat: add batch mode query endpoint#7
Merged
Conversation
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>
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.
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
YamlFileRepositorycache — so a batch costs ~one file read regardless of size.API contract
POST /api/whose-name/query/batch(inside the existingauth:sanctum+ability:whose-namegroup)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 username207 Multi-Status— at least one query returnednull(partial/total misses)422 Unprocessable Entity— malformed body (strict validation: 1–100 items, eachu/s/qrequired|string)Changes
QueryService::whatAreTheNamesOf()loops the existingwhatIsTheNameOf(), keeping iteration/ordering in the domain layer (framework stays a client of the domain).u/s/q→ domain and selecting 200/207.No DB/migration/binding changes; repository and interface untouched.
Verification
./vendor/bin/sail test --without-tty— 24 passed, 1 pre-existing skip; all new domain and endpoint tests green.🤖 Generated with Claude Code