forked from loopbackio/loopback.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getting-started-openapi-to-graphql.html
250 lines (229 loc) · 10.5 KB
/
getting-started-openapi-to-graphql.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
---
layout: blank
permalink: /getting-started-openapi-to-graphql.html
redirect_from: /getting-started-oasgraph
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<!-- not working -->
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<title>LoopBack 4</title>
<!-- Bootstrap core CSS -->
<link href="dist/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans" rel="stylesheet">
<link href="css/loopback.css" rel="stylesheet">
<link href="css/getting-started.css" rel="stylesheet">
<link href="css/openapi-to-graphql.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-150726441-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-150726441-2');
</script>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<a class="navbar-brand" href="index.html">
<img src="images/global/loopback-full-logo-blue.svg" width=150px>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="getting-started.html">Getting Started</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/doc/en/lb4">Docs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contribute.html">Contribute</a>
</li>
<li class="nav-item">
<a class="nav-link" href="resources.html">Resources</a>
</li>
<li class="nav-item">
<a class="nav-link" href="openapi-to-graphql.html">GraphQL</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://strongloop.com/strongblog/tag_LoopBack.html" target="_blank" rel="noopener noreferrer">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://ibm.biz/apitest" target="_blank" rel="noopener noreferrer">Test Your APIs</a>
</li>
</ul>
</div>
</nav>
<!-- Header -->
<div class="openapi-to-graphql-masthead">
<h2>Ready to translate REST to GraphQL?</h2>
<br/>
<h5 style="font-weight: normal">Let's get you equipped.</h5>
</div>
<section class="odd-section">
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 1</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Have you installed Node.js?</h3>
<p class="p large step">Before you install OpenAPI-to-GraphQL, make sure to download and install Node.js (version 8.9.x or higher), a JavaScript runtime.</p>
</div>
<div class="col-md-6">
<div class="col-md-6">
<a class="btn btn-secondary" style="padding-left:60px; padding-right:60px; top: 20%" role="button" href="https://nodejs.org/en/download/" target="_blank" rel="noopener noreferrer">Install Node.js</a>
</div>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step2" class="even-section">
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 2</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Install OpenAPI-to-GraphQL</h3>
<p class="p large step">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.</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<code-blue>$</code-blue> npm i -g openapi-to-graphql-cli
</pre>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step3" class="odd-section">
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 3</button>
</div>
<div class="col-md-12">
<h3 class="feature-heading">Save OAS</h3>
<p class="p large step">OpenAPI-to-GraphQL relies on the OpenAPI Specification (OAS) of an existing API to create a GraphQL interface around that API.</p>
</div>
<div class="col-md-6" style="padding-top: 30px;">
<p class="p large step">If you use LoopBack, start your API server in the LoopBack project folder, and access the API's OAS at <a class="link" href="http://127.0.0.1:3000/openapi.json">http://127.0.0.1:3000/openapi.json</a>. Save the OAS to disk.</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<span class="text-secondary"># in the LoopBack project folder:</span>
<code-blue>$</code-blue> npm start
</pre>
</div>
</div>
</div>
<div class="container">
<hr class="hairline"/>
<div class="row text-center">
<div class="col-md-12">
<p class="p large step">If you want to generate a GraphQL interface for another API, make sure that API is running and save its OAS.</p>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step4" class="even-section">
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 4</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Start GraphQL server</h3>
<p class="p large step">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 <a class="link" href="http://127.0.0.1:3001/graphql">http://127.0.0.1:3001/graphql</a>.</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<span class="text-secondary"># in the OpenAPI-to-GraphQL folder:</span>
<code-blue>$</code-blue> openapi-to-graphql <path to saved OAS>
</pre>
</div>
</div>
</div>
</section>
<!-- footer -->
<footer>
<div class="container">
<div class="row text-center">
<div class="col-md-3">
<img src="images/global/loopback-mark-frame-white.svg" width=40px/>
</div>
<div class="col-md-3">
<p class="label text-uppercase">Product</p>
<p class="regular">
<a href="getting-started.html">Getting Started</a>
</p>
<p class="regular">
<a href="doc/en/lb4/Tutorials.html">Tutorials</a>
</p>
</div>
<div class="col-md-3">
<p class="label text-uppercase" >Documentation</p>
<p class="regular">
<a href="/doc">Docs</a>
</p>
<p class="regular">
<a href="resources.html">Resources</a>
</p>
<p class="regular">
<a href="contribute.html">Contribute</a>
</p>
</div>
<div class="col-md-3">
<p class="label text-uppercase">Support</p>
<p class="regular">
<a href="/doc/en/lb4">LoopBack 4 Documentation</a>
</p>
<p class="regular">
<a href="https://loopback.io/doc/en/lb4/apidocs.index.html" target="_blank" rel="noopener noreferrer">API Docs</a>
</p>
<p class="regular">
<a href="https://strongloop.com/strongblog/" target="_blank" rel="noopener noreferrer">StrongLoop Blog</a>
</p>
<p class="regular">
<a href="https://www.ibm.com/marketplace/api-management" target="_blank" rel="noopener noreferrer">API Connect</a>
</p>
</div>
</div>
<hr class="hairline-footer">
<div class="row text-center">
<div class="col-md-6">
<p class="regular"> © Copyright 2020 StrongLoop, an IBM company</p>
</div>
<div class="col-md-6">
<p style="float:right">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet?text=Creating APIs has never been easier using %23LoopBack 4 by %40StrongLoop. Check it out at loopback.io.&url=loopback.io">
Tweet</a>
<a href="https://twitter.com/intent/tweet?screen_name=StrongLoop&ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-count="true">Tweet to @StrongLoop</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</p>
</div>
</div>
</div>
</footer>
<!-- Scripts -->
<script src="dist/jquery/jquery-3.3.1.slim.min.js"></script>
<script src="dist/popper/1.14.0/umd/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script src="dist/bootstrap/js/bootstrap.min.js"></script>
<!-- GitHub button -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>