Before you install OpenAPI-to-GraphQL, make sure to download and install Node.js (version 8.9.x or higher), a JavaScript runtime.
OpenAPI-to-GraphQL can be used either as a library, or via its Command Line Interface (CLI) to quickly get started. To install the OpenAPI-to-GraphQL CLI, simply run the indicated command.
$ npm i -g openapi-to-graphql-cli
OpenAPI-to-GraphQL relies on the OpenAPI Specification (OAS) of an existing API to create a GraphQL interface around that API.
If you use LoopBack, start your API server in the LoopBack project folder, and access the API's OAS at http://127.0.0.1:3000/openapi.json. Save the OAS to disk.
# in the LoopBack project folder:$ npm start
If you want to generate a GraphQL interface for another API, make sure that API is running and save its OAS.
Once OpenAPI-to-GraphQL is installed and the OAS is obtained, you can create and start the GraphQL server from the folder in which OpenAPI-to-GraphQL is installed. The created GraphQL server is then accessible at http://127.0.0.1:3001/graphql.
# in the OpenAPI-to-GraphQL folder:$ openapi-to-graphql