An example showing how to make a REST API available as GraphQL API through StepZen.
Before you're able to try out this example, you need to make sure that StepZen is installed on your local machine and that you're logged in. You can find how to do this in the Getting Started with StepZen guide.
After cloning this repository you need to run the following command to start this example:
stepzen start
This will make a GraphQL API available at http://localhost:5000/api/rest-example with the GraphiQL Playground.
This project is using My JSON Server to create a free REST API based on the contents of db.json
in this repository. You can view an example of this REST API here, and as you can see it has the following endpoints:
Based on the configuration that is passed to StepZen in index.graphql
and schema/ecommerce/graphql
, the schema for the GraphQL API is constructed. You can query the GraphQL API in example with the following query:
query GetProduct {
getProduct(id: 1) {
name
price
category {
name
}
rating {
average
}
}
}
This query will return product information from the REST API, by calling the endpoints /products/1
, /products/1/categories
and /products/1/rating
and returning all this data in one JSON blob.
Do you have any questions on this integration, or you want to check out other integrations you can make with [StepZen](https://stepzen.com/? Have a look at the website or join the Discord channel for support.