Prompt
Need data API with GraphQL and REST
Latest observation
Oct 1, 2026
OpenAI APIWeb search: off
Absolutely — if you need a data API that supports both GraphQL and REST, there are a few solid ways to design it depending on your stack and goals.
Common approaches
1) One backend, two API interfaces
Build a single service layer and expose:
- REST endpoints for simple CRUD and legacy clients
- GraphQL endpoint for flexible querying and aggregations
This is usually the best option if you want one source of truth for business logic.
2) REST-first with GraphQL gateway
Keep your existing REST API, then add a GraphQL layer on top that calls the REST services internally.
Good if:
- you already have REST APIs
- you want to add GraphQL without rewriting everything
3) GraphQL-first with REST compatibility
Design your core data layer around GraphQL, and expose selected REST endpoints for common operations, webhooks, or third-party integrations.
Good if:
- clients need flexible data fetching
- you still need REST for external integrations
Typical architecture
- Database
- Service layer for business logic
- REST controllers
- GraphQL resolvers
- Auth layer shared by both
- Validation / permissions shared by both
Suggested stack options
Depending on language/framework:
- Node.js
- REST: Express / Fastify / NestJS
- GraphQL: Apollo Server / GraphQL Yoga / NestJS GraphQL
- Python
- REST: FastAPI / Django REST Framework
- GraphQL: Strawberry / Ariadne / Graphene
- Java
- REST: Spring Boot
- GraphQL: Spring for GraphQL
- .NET
- REST: ASP.NET Core Web API
- GraphQL: Hot Chocolate
Design tips
- Keep business logic out of controllers/resolvers
- Use the same service layer for both REST and GraphQL
- Avoid duplicate data fetching logic
- Add pagination, filtering, and auth consistently
- Consider rate limiting and query complexity limits for GraphQL
Example API shape
REST
GET /usersGET /users/{id}POST /usersPATCH /users/{id}
GraphQL
type Query {
users(limit: Int, offset: Int): [User!]!
user(id: ID!): User
}
If you want the fastest path
If you're starting fresh, a practical choice is:
- FastAPI + Strawberry for Python
- NestJS for Node.js
- Spring Boot + Spring for GraphQL for Java
If you want, I can help you with one of these next:
- a full API design
- a sample codebase
- a schema + REST endpoint plan
- a recommendation for your stack