{"repo":"graphql-hive/SOFA","free":true,"listed":false,"github":"https://github.com/graphql-hive/SOFA","clone":"git clone https://github.com/graphql-hive/SOFA.git","description":"The best way to create REST APIs - Generate RESTful APIs from your GraphQL Server","language":"TypeScript","stars":1118,"topics":["api","graphql","openapi","rest","swagger"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"The best way to create REST APIs (is GraphQL). Installation yarn add sofa-api # or npm install sofa-api Getting Started Here's complete example with no dependency on frameworks, but also integratable with any of them: Another example with builtin express-like frameworks support How it works Sofa takes your GraphQL Schema, looks for available queries, mutations and subscriptions and turns all of that into REST API. Given the following schema: Routes that are being generated: Nested data and idea behind Models Sofa treats some types differently than others, those are called Models. The idea behind Models is to not expose full objects in every response, especially if it's a nested, not first-level data. For example, when fetching a list of chats you don't want to include all messages in the response, you want them to be just IDs (or links). Those messages would have to have their own endpoint. We call this type of data, a Model. In REST you probably call them Resources. In order to treat particular types as Models you need to provide two queries, one that exposes a list (with no non-optional arguments) and the other to fetch a single entity (id field as an argument). The model itself has to have an id field. Those are the only requirements. Provide a Context In order for Sofa to resolve operations based on a Context, you need te be able to provide some. Here's how you do it: You can pass a plain object or a function. Use full responses instead of IDs There are some cases where s","default_branch":null,"files":null,"tree":[],"storefront":"/r/graphql-hive","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/graphql-hive/SOFA/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}