Skip to content

Backend: Add GraphQL API layer alongside REST #336

@CelestinaBeing

Description

@CelestinaBeing

Summary

The REST API serves campaign data well for simple CRUD, but integrators building complex dashboards (e.g. 'give me all active campaigns with their stats and the last 5 audit log entries in one request') suffer from N+1 request patterns. A GraphQL layer enables efficient data fetching for complex queries.

Problem

  • Frontend must make 3+ round trips to get campaign + stats + audit logs
  • No subscription mechanism for real-time updates
  • Third-party integrators building analytics tools cannot query exactly what they need

Acceptance Criteria

  • Add graphql + graphql-yoga (or apollo-server-express) to backend/package.json
  • Mount GraphQL at /graphql with GraphiQL explorer (enabled in dev via env flag)
  • Schema: Campaign, AuditLog, Stats, Config types with all existing REST fields
  • Queries: campaigns(filter, sort, limit, cursor), campaign(id), stats, config
  • Mutations: createCampaign, updateCampaign, deleteCampaign (API key auth)
  • DataLoader for batched DB queries (prevent N+1)
  • Apply the same rate limiter and API key auth middleware as REST
  • Add unit tests for resolvers
  • Document in backend/openapi.yaml (note: separate schema at /graphql)

References

  • backend/src/index.js
  • backend/src/dal/

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions