Description
Some integrators prefer GraphQL over REST for flexible queries (e.g. fetching invoice plus payer reputation in a single request). Adding an optional GraphQL API layer to the indexer makes it a more versatile data source.
Requirements and context
- Use
graphql-yoga to add a GraphQL endpoint at /graphql
- Schema types mirroring existing REST resources:
Invoice, ReputationScore, GovernanceProposal, ContractStats
- Queries:
invoice(id), invoices(filter, pagination), reputation(address), leaderboard(limit), stats
- Each query must resolve from the same indexed database as the REST API (no duplicate data stores)
- Write resolver tests and include the GraphQL playground in development mode
Suggested execution
git checkout -b feat/indexer-graphql
- Install
graphql-yoga
- Define schema in
indexer/src/api/graphql/schema.ts
- Implement resolvers in
indexer/src/api/graphql/resolvers.ts
- Write resolver unit tests
Example commit message
feat(indexer): add optional GraphQL API layer with invoice, reputation, and stats queries
Description
Some integrators prefer GraphQL over REST for flexible queries (e.g. fetching invoice plus payer reputation in a single request). Adding an optional GraphQL API layer to the indexer makes it a more versatile data source.
Requirements and context
graphql-yogato add a GraphQL endpoint at/graphqlInvoice,ReputationScore,GovernanceProposal,ContractStatsinvoice(id),invoices(filter, pagination),reputation(address),leaderboard(limit),statsSuggested execution
graphql-yogaindexer/src/api/graphql/schema.tsindexer/src/api/graphql/resolvers.tsExample commit message
feat(indexer): add optional GraphQL API layer with invoice, reputation, and stats queries