The-Devoyage / subgraph

A POC written in rust to generate a functional API based on a simple config/schema.
GNU General Public License v3.0
7 stars 0 forks source link

Create HTTP Data Source #23

Closed nickisyourfan closed 1 year ago

nickisyourfan commented 1 year ago

Users will be able to choose to use a RESTful/HTTP API as a data source, essentially converting a RESTful API into GraphQL with Federation 2 support.

Defining The Data Source

  1. The user will first define the data source at the top level of the config.
[[service.data_sources]]
[service.data_sources.HTTP]
name = "business"
url = "https://jsonplaceholder.typicode.com/"
[[service.data_sources.HTTP.default_headers]]
header = "Authorization"
value = "Bearer token_123456789"
  1. By default, the same endpoint will be used for each resolver. HTTP Method will change depending on resolver functionality.
  2. Users will be able to adjust endpoint per entity.
[service.entities.data_source]
from = "business"
endpoint = "/todos"

...

[service.entities.data_source]
from = "business"
endpoint = "/notes"
  1. Users will be able to adjust endpoint per resolver. They can use properties defined in the entity or custom input as variables for query params. Users will be able to adjust inputs for each resolver.
[service.entities.data_source]
from = "todos"
endpoint = "/todos"
[[service.entities.data_source.resolvers]]
[service.entities.data_source.resolvers.GetOne]
endpoint = "/:id"
[service.entities.data_source.resolvers.CreateOne]
[[service.entities.data_source.resolvers.CreateOne.fields]]
...Field Type