Repository navigation
feat: add volumes and spreads GraphQL queries with REST parity - #613
Conversation
…ity-Labs#368) Adds `volumes(asset, window, network)` and `spreads(asset, window, network)` GraphQL queries. Each resolver calls the REST route's own implementation, now extracted as `computeVolumes` (src/routes/volumes.ts) and `computeSpreads` (src/routes/spreads.ts), so REST and GraphQL cannot drift. - Per-venue results are a typed `[VenueQuote!]!` list (REST's `byVenue` map becomes a list for volumes; spreads keep (venue, pair) entries). - Both queries are network-aware: `network` defaults to the active network, and a bad `network` or `window` fails with INVALID_INPUT and the same message REST returns with its 400. - REST behaviour is unchanged: same validation, SQL, response and errors. - schema.graphql regenerated from the code schema; docs/graphql.md updated. - New src/__tests__/graphqlVolumesSpreads.test.ts drives both surfaces of one server with the same rows and asserts parity. Closes Divinity-Labs#368
abac5bc to
5367e5b
Compare
|
Merged as You did the thing that matters: the resolvers call Exporting Merge note — one thing I had to carry acrossBoth conflicts were in the files your extraction moves, because The good news: your branch already had #455's net/gross split and What it predated was #394, merged about half an hour before this, which moved these windows off -- before
AND timestamp >= $3
-- after
AND COALESCE(observed_at, timestamp) >= $3
Taking the extraction verbatim would have silently reverted that in precisely the two queries #394 was written to fix. Carried across in both files, including the spreads query's Nothing for you to do — flagging it because it is the hazard of extracting a query that is being edited underneath you: the conflict shows up as "your function vs their inline SQL", and taking your side looks obviously right while quietly dropping their change. Regenerated 137 test files / 1,663 tests pass; |
Overview
This PR adds
volumesandspreadsGraphQL queries that mirror the existing/volumes/:assetand/spreads/:assetREST routes. Spreads are returned per venue as a typedVenueQuotelist so callers can select only the fields they need for each venue. Both queries are network-aware and share their implementation with the REST routes.Related Issue
Changes
🔌 GraphQL Surface
[MODIFY]
schema.graphqlvolumesandspreadsquery fields.VenueQuoteobject type so per-venue spread results are a list of typed objects rather than a map or string.[MODIFY]
src/api/graphql.tsvolumesandspreadsresolvers into the mercurius schema.🔁 Shared Implementation
src/routes/spreads.ts✅ Tests
src/__tests__/spreads.test.tsspreadsresult matches the REST response for the same input, per venue.Verification Results
spreadscovered by parity test;volumesschema and resolver addedVenueQuotelist type inschema.graphqlsrc/routes/spreads.tssrc/__tests__/spreads.test.tsCloses #368