Generate RESTful APIs automatically from your existing GraphQL server.
Sofa is a Node.js library that automatically generates RESTful APIs from an existing GraphQL server. It translates GraphQL queries, mutations, and subscriptions into traditional REST endpoints, allowing teams to serve both GraphQL and REST APIs from the same schema. This solves the problem of maintaining separate API layers or forcing clients to adopt GraphQL exclusively.
Backend developers and API architects who have a GraphQL server but need to provide REST endpoints for legacy clients, third-party integrations, or teams not yet ready to adopt GraphQL.
Developers choose Sofa because it eliminates the need to manually build and maintain REST APIs alongside GraphQL, reducing duplication and ensuring consistency. Its unique selling point is the automatic, schema-driven generation of REST routes with customization options and built-in OpenAPI support.
The best way to create REST APIs - Generate RESTful APIs from your GraphQL Server
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Sofa automatically creates REST endpoints from GraphQL queries, mutations, and subscriptions, eliminating manual REST coding, as shown in the 'How it works' section where routes like GET /chats are generated from the schema.
Allows fine-grained control over HTTP methods, paths, and response status codes for generated routes, enabling developers to tailor REST APIs beyond default mappings, detailed in the 'Customize endpoint's HTTP Method' section.
Generates OpenAPI definitions directly from the GraphQL schema, streamlining API documentation and integration with tools like Swagger, as demonstrated with examples for adding security schemes and tags.
Converts GraphQL subscriptions into webhook-based endpoints, facilitating event-driven architectures for systems that don't support GraphQL, with management APIs for starting, stopping, and updating subscriptions.
REST endpoints are directly derived from the GraphQL schema, meaning any schema changes can break or alter REST APIs unexpectedly, requiring careful versioning and client updates.
By default, Sofa exposes nested models as IDs to prevent over-fetching, but configuring full object responses requires manual 'ignore' settings, adding complexity for deep or dynamic data structures.
Converting subscriptions to webhooks introduces additional infrastructure needs, such as webhook endpoint reliability and scaling, which may not be suitable for all real-time use cases compared to native GraphQL subscriptions.