Make sure you have a running LoopBack 4 application. In this tutorial, we’ll usethe example. You can create this application by running the commandbelow:
From your LoopBack application, run the following command to installOpenAPI-to-GraphQL and the required dependencies:
npm i --save openapi-to-graphql-cli
Make sure your LoopBack application is running by going to. If not, you can start it by running the
npm start
command.
Haven’t heard about npx
yet? It’s a cool helper provided by npm
andavailable out of the box since Node.js 8.x. Learn more in their announcementblog post:Introducing npx: an npm package runner
That’s it! You’re now ready to try out some tests and requests in the browser at.
Note:
Here are some examples of the query
and calls:
- To get all the to-do instances, run this query command:
todos {
id
title
desc
}
The expected output looks like this:
mutation {
todoControllerCreateTodo(todoInput: {
title: "Take over the universe"
}) {
id
title
}
The expected output looks like this: