[Backend] High-Performance GraphQL API & Real-Time Subscription Gateway
Overview & Background
As FlowFi's data model expands with streams, token metadata, dead-letter triage events, webhooks, and multi-network deployments, clients require granular, deeply nested queries without suffering from REST over-fetching or under-fetching. Providing a native GraphQL schema with real-time subscriptions enables frontend dashboards, mobile wallets, and external integrators to fetch exact entity graphs in a single network round-trip.
Detailed Problem Statement
- REST Over-Fetching and Multi-Endpoint Cascades:
- The frontend currently makes separate round-trips to
/streams/incoming,/streams/outgoing,/tokens, and/metricsto render a single dashboard view.
- The frontend currently makes separate round-trips to
- N+1 Database Query Inefficiencies:
- Complex relational views (e.g. Streams with their associated events, token metadata, and audit logs) risk N+1 Prisma query storms without DataLoader batching.
- Fragmented Subscription Protocols:
- Real-time updates currently rely on disparate SSE routes (
/api/v1/events/stream) and WebSockets without unified typed schema introspection.
- Real-time updates currently rely on disparate SSE routes (
Technical Specification & Architecture
1. GraphQL Engine (@apollo/server or graphql-yoga + pothos)
Implement a modular schema in backend/src/graphql/:
- Types:
Stream: id, sender, recipient, token, depositedAmount, withdrawnAmount, claimableAmount, ratePerSecond, startTime, endTime, status, events, positions.Token: address, symbol, name, decimals, iconUrl.StreamEvent: id, streamId, eventType, transactionHash, ledgerSequence, timestamp.
- Queries:
stream(id: ID!): Streamstreams(filter: StreamFilterInput, pagination: PaginationInput): StreamConnection!accountOverview(address: String!): AccountOverview!
- Subscriptions:
streamUpdated(streamId: ID!): Stream!userStreams(address: String!): StreamEvent!
2. Dataloader Batching Layer
- Implement DataLoaders in
backend/src/graphql/dataloaders/:batchStreamsByIds: Batches stream lookups into single SQLWHERE id IN (...).batchEventsByStreamIds: Groups events for multiple streams in a single indexed query.batchTokensByAddresses: In-memory cached token metadata lookups.
3. Integration & Middleware
- Mount at
POST /graphqlandGET /graphql(GraphiQL playground in non-production). - Integrate existing auth, rate limiting, and OpenTelemetry request context into GraphQL execution context.
Target Files
backend/src/graphql/schema.tsbackend/src/graphql/resolvers/stream.resolver.tsbackend/src/graphql/dataloaders/index.tsbackend/src/graphql/context.tsbackend/src/app.tsbackend/tests/graphql.test.ts
Acceptance Criteria
- [ ] GraphQL endpoint passes introspection queries and validates schema against TypeScript types.
- [ ] DataLoaders eliminate N+1 queries for nested stream-to-events relations (verified via query logging).
- [ ] Pagination conforms to Relay connection cursor specification (
edges,node,pageInfo). - [ ] GraphQL subscriptions deliver real-time stream state changes matching SSE/indexer events.
- [ ] Integration test suite covers authorization, filters, and error formatting.
@Righteous-81 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
I would like to solve this issue and return it to it's normal operation
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Righteous-81 to this issue.
@Osifowora has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
Hi maintainer, I would love to work on this issue. I can get started on it right away.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Osifowora to this issue.
Congratulations, @Osifowora! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.
🧑💻 @Osifowora: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
This issue has been marked as completed by a Drips Wave moderator for @Osifowora as part of the Stellar Wave Program's 9th Wave 🥳
Moderator's reason: [Auto-assessed] The PR (#1524) was merged by maintainers (evidenced by the merge state and commit trail) and fully implements the GraphQL gateway, DataLoader batching, schema, resolvers, and subscriptions requested in Issue #1467, along with the other cross-cutting features. All requirements are thoroughly addressed and tested.
😎 @Osifowora: You earned 150 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.
ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.
@anasisgay16 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello maintainer, i would like to work on this issue
ℹ️ Repo Maintainers: To accept this application, review their application or assign @anasisgay16 to this issue.
Congratulations, @anasisgay16! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @anasisgay16: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊