LoopBack4 and OASGraph
GraphQL in minutes!
By Mario Estrada
marioestradarosa@gmail.com
What is OASGraph?
Turns APIs described by OpenAPI specifications (OAS) into GraphQL
interfaces.



https://github.com/strongloop/oasgraph
What is LoopBack 4?
LoopBack 4 makes it easy to build modern applications that require
complex integrations.
• Fast, small, powerful, extensible core
• Generate real APIs with a single command
• Define your data and endpoints with OpenAPI
https://github.com/strongloop/loopback-next
Loopback 4 High Level Overview
LoopBack 4
DB
SOAP
REST
Open API specification
{ REST SERVER }
REST
OasGraph Integration Overview
LoopBack 4
OASGraph Library
Open API

Specification
GraphQL Schema
Express-graphql
REST
GraphQL
Let’s code !
INSTALLING LOOPBACK4
npm install -g @loopback/cli
Generating todo-list example
lb4 example todo-list
INSTALL OASGRAPH DEPENDENCY
npm install oasgraph —save
cd loopback4-example-todo-list
npm install express-graphql —save
Modify src/application.ts
options = Object.assign({}, {
rest: {
openApiSpec: {
servers: [{url:'http://localhost:3000'}],
}
}
});
Add the following code before the super(options); 

This will help OASGraph determine the URL for the resolver(s).
At runtime the OpenApi Spec parameter
OpenAPI Spec
options = Object.assign({}, {
rest: {
openApiSpec: {
servers: [{url:'http://
localhost:3000'}],
}
}
});
GraphQL Schema
"servers": [
{
"url": "http://localhost:3000/"
}
],
Resolver URL
Modify src/index.ts
Import dependencies
This will make the the express, express-graphql and oasgraph available.
const OASGraph = require('oasgraph');
const express = require('express');
const graphqlHTTP = require('express-graphql');
Modify src/index.ts
Create the Schema Object
Note that we are using the method getApiSpec from the LoopBack 4 rest server. This is the
magic, the OASGraph.createGraphQlSchema is converting it to a GraphQL Schema
automatically and accurately.
const {schema} = await
OASGraph.createGraphQlSchema(
app.restServer.getApiSpec(),
{
strict: false,
viewer: true,
addSubOperations: true,
sendOAuthTokeninQuery: false,
},
);
Note: This code will be wrapped inside a try/catch. And starts after line console.log(`Try ${url}/ping`);
LoopBack 4
OASGraph Library
Open API

Specification
Modify src/index.ts
Starts the GraphQL Server
With the GraphQL schema generated already, it is just a matter of starting the GraphQL
server in a specific port, in this case, we are using port 3001.
const myExpress = express();
myExpress.use('/graphql', graphqlHTTP(
{
schema: schema,
graphiql: true,
}
));
myExpress.listen(3001, () => {
console.log('OASGraph ready at http://localhost:3001/graphql');
});
Note: This code will be wrapped inside a try/catch.
OASGraph Library
GraphQL Schema
Express-graphql
Full code
src/index.ts
The following code, should placed after rest server has been initiated.

try {
const {schema} = await OASGraph.createGraphQlSchema(
app.restServer.getApiSpec(),
{
strict: false,
viewer: true,
addSubOperations: true,
sendOAuthTokeninQuery: false,
},
);
const myExpress = express();
myExpress.use('/graphql', graphqlHTTP({schema: schema, graphiql: true}));
myExpress.listen(3001, () => {
console.log('OASGraph ready at http://localhost:3001/graphql');
});
} catch (err) {
console.log('Error: ', err.message);
}
return app;

}
Now run the application
npm start
> node .
Server is running at http://[::1]:3000
OASGraph ready at http://localhost:3001/graphql
End point for GraphQL Server
Use GraphiQL tool
Open in browser at http://localhost:3001/graphql
GraphiQL Tool
http://localhost:3001/graphql
Thank you !
Visit http://v4.loopback.io

More Related Content

PPTX
Airflow 101
PDF
Gatling @ Scala.Io 2013
PDF
React meets o OCalm
PDF
rx-java-presentation
PPTX
Airflow at WePay
PDF
Graphs: Fabric of DevOps
PDF
Airflow presentation
PDF
How I learned to time travel, or, data pipelining and scheduling with Airflow
Airflow 101
Gatling @ Scala.Io 2013
React meets o OCalm
rx-java-presentation
Airflow at WePay
Graphs: Fabric of DevOps
Airflow presentation
How I learned to time travel, or, data pipelining and scheduling with Airflow

What's hot (20)

PDF
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
PDF
Building an analytics workflow using Apache Airflow
PDF
Apache airflow
ODP
Gatling - Stress test tool
PDF
Introducing Apache Airflow and how we are using it
PDF
Continuous performance management with Gatling
PDF
Apache Airflow
PDF
Load test REST APIs using gatling
PDF
Airflow Best Practises & Roadmap to Airflow 2.0
PPTX
Apache Airflow Introduction
PPTX
Grails Plugin
PPTX
Where is my scalable api?
PDF
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
PDF
Retrofit
PPTX
Top 10 RxJs Operators in Angular
PDF
V8 javascript engine for フロントエンドデベロッパー
PDF
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
PDF
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
PDF
FullStack Reativo com Spring WebFlux + Angular
PDF
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
Building an analytics workflow using Apache Airflow
Apache airflow
Gatling - Stress test tool
Introducing Apache Airflow and how we are using it
Continuous performance management with Gatling
Apache Airflow
Load test REST APIs using gatling
Airflow Best Practises & Roadmap to Airflow 2.0
Apache Airflow Introduction
Grails Plugin
Where is my scalable api?
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
Retrofit
Top 10 RxJs Operators in Angular
V8 javascript engine for フロントエンドデベロッパー
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
FullStack Reativo com Spring WebFlux + Angular
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Ad

Similar to OASGraph LoopBack 4 Integration (20)

PDF
How easy (or hard) it is to monitor your graph ql service performance
PDF
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
PDF
GraphQL across the stack: How everything fits together
PDF
The GrapQL ecosystem
PPT
Graphql presentation
PDF
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
PPTX
Graph ql subscriptions on the jvm
PDF
Cascading on starfish
PDF
Graphql usage
PDF
What is new in java 8 concurrency
ODP
Developingapiplug insforcs-151112204727-lva1-app6891
PPTX
Java Libraries You Can’t Afford to Miss
PDF
Arquitecturas de microservicios - Medianet Software
PDF
GraphQL over REST at Reactathon 2018
PDF
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
PPTX
Graph ql subscriptions through the looking glass
PDF
GraphQL in Apache Sling - but isn't it the opposite of REST?
PDF
Angular for Java Enterprise Developers: Oracle Code One 2018
PDF
Boost your API with GraphQL
PPTX
How to provide a GraphQL API - I want it that way
How easy (or hard) it is to monitor your graph ql service performance
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
GraphQL across the stack: How everything fits together
The GrapQL ecosystem
Graphql presentation
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Graph ql subscriptions on the jvm
Cascading on starfish
Graphql usage
What is new in java 8 concurrency
Developingapiplug insforcs-151112204727-lva1-app6891
Java Libraries You Can’t Afford to Miss
Arquitecturas de microservicios - Medianet Software
GraphQL over REST at Reactathon 2018
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
Graph ql subscriptions through the looking glass
GraphQL in Apache Sling - but isn't it the opposite of REST?
Angular for Java Enterprise Developers: Oracle Code One 2018
Boost your API with GraphQL
How to provide a GraphQL API - I want it that way
Ad

Recently uploaded (20)

PPTX
Presentation - Summer Internship at Samatrix.io_template_2.pptx
PDF
Mobile App for Guard Tour and Reporting.pdf
PPTX
FLIGHT TICKET API | API INTEGRATION PLATFORM
PPTX
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
PDF
IT Consulting Services to Secure Future Growth
PPTX
Foundations of Marketo Engage: Nurturing
PPTX
Lesson-3-Operation-System-Support.pptx-I
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
PPTX
Relevance Tuning with Genetic Algorithms
PPTX
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PDF
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
PDF
Module 1 - Introduction to Generative AI.pdf
PDF
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
PDF
Odoo Construction Management System by CandidRoot
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PPTX
Greedy best-first search algorithm always selects the path which appears best...
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
PDF
Multiverse AI Review 2025_ The Ultimate All-in-One AI Platform.pdf
PDF
Adlice Diag Crack With Serial Key Free Download 2025
Presentation - Summer Internship at Samatrix.io_template_2.pptx
Mobile App for Guard Tour and Reporting.pdf
FLIGHT TICKET API | API INTEGRATION PLATFORM
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
IT Consulting Services to Secure Future Growth
Foundations of Marketo Engage: Nurturing
Lesson-3-Operation-System-Support.pptx-I
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
Relevance Tuning with Genetic Algorithms
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
ROI from Efficient Content & Campaign Management in the Digital Media Industry
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
Module 1 - Introduction to Generative AI.pdf
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
Odoo Construction Management System by CandidRoot
Top 10 Project Management Software for Small Teams in 2025.pdf
Greedy best-first search algorithm always selects the path which appears best...
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
Multiverse AI Review 2025_ The Ultimate All-in-One AI Platform.pdf
Adlice Diag Crack With Serial Key Free Download 2025

OASGraph LoopBack 4 Integration

  • 1. LoopBack4 and OASGraph GraphQL in minutes! By Mario Estrada [email protected]
  • 2. What is OASGraph? Turns APIs described by OpenAPI specifications (OAS) into GraphQL interfaces.
 
 https://github.com/strongloop/oasgraph What is LoopBack 4? LoopBack 4 makes it easy to build modern applications that require complex integrations. • Fast, small, powerful, extensible core • Generate real APIs with a single command • Define your data and endpoints with OpenAPI https://github.com/strongloop/loopback-next
  • 3. Loopback 4 High Level Overview LoopBack 4 DB SOAP REST Open API specification { REST SERVER } REST
  • 4. OasGraph Integration Overview LoopBack 4 OASGraph Library Open API
 Specification GraphQL Schema Express-graphql REST GraphQL
  • 8. INSTALL OASGRAPH DEPENDENCY npm install oasgraph —save cd loopback4-example-todo-list npm install express-graphql —save
  • 9. Modify src/application.ts options = Object.assign({}, { rest: { openApiSpec: { servers: [{url:'http://localhost:3000'}], } } }); Add the following code before the super(options); This will help OASGraph determine the URL for the resolver(s).
  • 10. At runtime the OpenApi Spec parameter OpenAPI Spec options = Object.assign({}, { rest: { openApiSpec: { servers: [{url:'http:// localhost:3000'}], } } }); GraphQL Schema "servers": [ { "url": "http://localhost:3000/" } ], Resolver URL
  • 11. Modify src/index.ts Import dependencies This will make the the express, express-graphql and oasgraph available. const OASGraph = require('oasgraph'); const express = require('express'); const graphqlHTTP = require('express-graphql');
  • 12. Modify src/index.ts Create the Schema Object Note that we are using the method getApiSpec from the LoopBack 4 rest server. This is the magic, the OASGraph.createGraphQlSchema is converting it to a GraphQL Schema automatically and accurately. const {schema} = await OASGraph.createGraphQlSchema( app.restServer.getApiSpec(), { strict: false, viewer: true, addSubOperations: true, sendOAuthTokeninQuery: false, }, ); Note: This code will be wrapped inside a try/catch. And starts after line console.log(`Try ${url}/ping`); LoopBack 4 OASGraph Library Open API
 Specification
  • 13. Modify src/index.ts Starts the GraphQL Server With the GraphQL schema generated already, it is just a matter of starting the GraphQL server in a specific port, in this case, we are using port 3001. const myExpress = express(); myExpress.use('/graphql', graphqlHTTP( { schema: schema, graphiql: true, } )); myExpress.listen(3001, () => { console.log('OASGraph ready at http://localhost:3001/graphql'); }); Note: This code will be wrapped inside a try/catch. OASGraph Library GraphQL Schema Express-graphql
  • 14. Full code src/index.ts The following code, should placed after rest server has been initiated. try { const {schema} = await OASGraph.createGraphQlSchema( app.restServer.getApiSpec(), { strict: false, viewer: true, addSubOperations: true, sendOAuthTokeninQuery: false, }, ); const myExpress = express(); myExpress.use('/graphql', graphqlHTTP({schema: schema, graphiql: true})); myExpress.listen(3001, () => { console.log('OASGraph ready at http://localhost:3001/graphql'); }); } catch (err) { console.log('Error: ', err.message); } return app;
 }
  • 15. Now run the application npm start > node . Server is running at http://[::1]:3000 OASGraph ready at http://localhost:3001/graphql End point for GraphQL Server
  • 16. Use GraphiQL tool Open in browser at http://localhost:3001/graphql
  • 18. Thank you ! Visit http://v4.loopback.io