feat(guilds): add getGuildConfigBatch for batched guild configuration lookups - #436
Merged
Lakes41 merged 1 commit intoJul 29, 2026
Merged
Conversation
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.
Closes #389.
Two things settled before writing code
BatchItemResultcould not carry aGuildConfigas written.src/contracts/contract.types.ts:83declared
result?: string, documented as raw hex from the contract batch methods. Reusing it —which the issue asks for — means making it generic:
The
stringdefault leaves every existing contract call site and every consumer's typesource-compatible; only methods resolving richer values parameterise it.
A batch added only to the service would have silently bypassed the cache.
GuildPassClientwrapsgetGuildConfiginwithCache, butgetGuildConfigBatchcallsthis.getGuildConfiginternally — against the raw service, so nothing would be cached and afollow-up single lookup would refetch.
checkAccessBatchalready solved this with aneverCoalesceproxy that still caches per item but opts out of in-flight dedup, and thismirrors it: coalescing inside a batch would let one caller's abort or failure affect an
unrelated caller sharing a key. Three tests pin the wiring.
Also worth noting
The issue lists
src/services/guilds.tsandtests/services.test.ts.GuildsServiceactuallylives in
src/guilds/guilds.service.ts, andtests/guilds.service.test.tsis where its testsare, so those are the files touched.
tests/fixtures/api-contract.json:131already pins/guilds/guild_1/config, so a client-side fan-out needs no new fixture shape.Implementation
getGuildConfigBatch(params, options?)returnsBatchItemResult<GuildConfig>[], one entry perinput ID in input order, with per-guild failure isolation matching
getGuildOwnersBatch.It is a client-side fan-out over the existing
GET /guilds/:id/configendpoint — no batchendpoint is assumed — issued through a bounded worker pool rather than all at once. Each worker
claims its index before awaiting, so results land at their own input position regardless of
response order.
concurrencydefaults to5and caps at50, matchingcheckAccessBatch;there is no shared batch helper in the repo to reuse, so this follows the same inline
worker-pool shape
AccessServicealready uses.includeMetais dropped for the inner calls: per-item metadata has nowhere to live inBatchItemResult.Tests
+13, no existing test modified.
tests/guilds.service.test.ts(+9): order preservation; order preserved when responses resolveout of order (the slow-first case, which a naive
pushwould reorder); single-guild failureisolation;
INVALID_INPUTfor empty, missing, non-array andundefinedguildIds;out-of-range
concurrency; an observed in-flight peak proving the concurrency bound; duplicateIDs each getting their own slot; and an invalid guild ID surfacing as a per-item error rather
than throwing the batch.
tests/cache.test.ts(+4): a batch call populating the per-guild cache; a later single lookupserved from it without a second request; the batch reading through entries a previous call
stored (only the uncached guild hits the network); and the no-adapter path still working.
Verification
No failures before or after.
pnpm buildexits 0. ESLint reports 0 errors on the touched files(the
no-explicit-anywarnings are pre-existing and none are on changed lines).Note on the api-report diff
api-report/guildpass-sdk.api.mdwas regenerated withpnpm build && pnpm api-report. Beyondthe
BatchItemResult<T>andgetGuildConfigBatchentries, the regenerated report also picks upAuthenticationProvider,ApiKeyAuthenticationProviderand the circuit-breaker hooks from thefeat/auth-providersmerge (add30e4), which landed without refreshing the report. Those linesare not part of this change; they appear because the report was stale on
main.