You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document lists the differences between the contribution guidelines for
4
-
this repository and the general [**Contributing to LoopBack**](http://loopback.io/doc/en/contrib/index.html) guidelines.
3
+
This document lists the differences between the contribution guidelines for this repository and the general [**Contributing to LoopBack**](http://loopback.io/doc/en/contrib/index.html) guidelines.
5
4
6
5
### Developer Certificate of Origin
7
6
8
-
This repository uses a [Developer Certificate of Origin (DCO)](https://developercertificate.org/) instead of a
9
-
[Contributor License Agreement](https://cla.strongloop.com/agreements/strongloop/loopback.io) like most other LoopBack repositories. DCO
10
-
is an easier process to adhere to. [Full text of DCO](https://developercertificate.org/) can be found below, formatted
11
-
for readability.
7
+
This repository uses a [Developer Certificate of Origin (DCO)](https://developercertificate.org/) instead of a [Contributor License Agreement](https://cla.strongloop.com/agreements/strongloop/loopback.io) like most other LoopBack repositories. DCO is an easier process to adhere to. [Full text of DCO](https://developercertificate.org/) can be found below, formatted for readability.
12
8
13
9
> By making a contribution to this project, I certify that:
14
10
>
15
-
> (a) The contribution was created in whole or in part by me and I
16
-
have the right to submit it under the open source license
17
-
indicated in the file; or
11
+
> (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
18
12
>
19
-
> (b) The contribution is based upon previous work that, to the best
20
-
of my knowledge, is covered under an appropriate open source
21
-
license and I have the right under that license to submit that
22
-
work with modifications, whether created in whole or in part
23
-
by me, under the same open source license (unless I am
24
-
permitted to submit under a different license), as indicated
25
-
in the file; or
13
+
> (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
26
14
>
27
-
> (c) The contribution was provided directly to me by some other
28
-
person who certified (a), (b) or (c) and I have not modified
29
-
it.
15
+
> (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
30
16
>
31
-
> (d) I understand and agree that this project and the contribution
32
-
are public and that a record of the contribution (including all
33
-
personal information I submit with it, including my sign-off) is
34
-
maintained indefinitely and may be redistributed consistent with
35
-
this project or the open source license(s) involved.
17
+
> (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
36
18
37
19
Contributors sign-off that they adhere to these requirements by adding a Signed-off-by line to commit messages.
38
20
@@ -56,14 +38,14 @@ If you've pushed a commit and forgot to sign it, fear not, you can sign it as fo
56
38
git commit --amend -s
57
39
```
58
40
59
-
Modify the commit message (if desired) -- do not modify the `Signed-off-by` line. Exit edit mode (`esc` followed by `:x` and then `Enter`).
41
+
Modify the commit message (if desired) -- do not modify the `Signed-off-by` line. Exit edit mode (`esc` followed by `:x` and then `Enter`).
60
42
61
43
Now force-push the changes by running:
44
+
62
45
```
63
46
git push origin +[branch-name]
64
47
```
65
48
66
49
Refer to the [official documentation](https://help.github.com/articles/changing-a-commit-message/#amending-older-or-multiple-commit-messages) for modifying multiple commits or an example with screenshots.
67
50
68
51
If all else fails, ask the LoopBack team for help :)
[](https://gitter.im/oasgraph/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
5
+
# OpenAPI-to-GraphQL
5
6
6
-
# OASGraph
7
7
Translate APIs described by [OpenAPI Specifications (OAS)](https://github.com/OAI/OpenAPI-Specification) into [GraphQL](https://graphql.org/).
8
8
9
-
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/translation.png"alt="Overview of translation"width="600">
10
-
9
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/translation.png"alt="Overview of translation"width="600">
11
10
12
11
## Getting started
13
-
OASGraph can be used in two ways:
14
12
13
+
OpenAPI-to-GraphQL can be used in two ways:
15
14
16
15
### CLI
17
-
The Command Line Interface (CLI) provides a convenient way to start a GraphQL server wrapping an API for a given OpenAPI Specification:
18
16
19
-
1. Install the OASGraph CLI using:
20
-
```bash
21
-
npm i -g oasgraph-cli
22
-
```
23
-
2. Then, run the OASGraph command and point it to an OpenAPI Specification:
24
-
```bash
25
-
oasgraph <OAS JSON file path or remote url> [options]
26
-
```
17
+
The Command Line Interface (CLI) provides a convenient way to start a GraphQL server wrapping an API for a given OpenAPI Specification:
27
18
28
-
For further details, refer to the [`oasgraph-cli` documentation](./packages/oasgraph-cli).
19
+
1. Install the OpenAPI-to-GraphQL CLI using:
20
+
```bash
21
+
npm i -g openapi-to-graphql-cli
22
+
```
23
+
2. Then, run the OpenAPI-to-GraphQL command and point it to an OpenAPI Specification:
24
+
```bash
25
+
openapi-to-graphql <OAS JSON file path or remote url> [options]
26
+
```
29
27
28
+
For further details, refer to the [`openapi-to-graphql-cli` documentation](./packages/openapi-to-graphql-cli).
30
29
31
30
### Library
32
-
Use OASGraph as a library in your application to generate GraphQL schemas.
33
31
34
-
1. Install OASGraph as a dependency:
35
-
```bash
36
-
npm i -s oasgraph
37
-
```
38
-
2. Require OASGraph and use the `createGraphQlSchema` function:
For further details, refer to the [`openapi-to-graphql` documentation](./packages/openapi-to-graphql).
47
46
48
47
## Tutorials
49
-
Here are some guides to further help you get started:
50
48
51
-
* [CLI + Loopback tutorial](./docs/tutorials/cli_loopback.md): Learn how to quickly spin up GraphQL wrappers using the OASGraph CLI.
52
-
* [Library tutorial](./docs/tutorials/watson.md): Learn how to use OASGraph as a library, and how to improve the resulting GraphQL wrappers using OAS `link` definitions.
53
-
* [LoopBack tutorial](./docs/tutorials/loopback.md): Learn how to use OASGraph to create GraphQL wrappers for APIs created with LoopBack 4.
49
+
Here are some guides to further help you get started:
54
50
51
+
-[CLI + Loopback tutorial](./docs/tutorials/cli_loopback.md): Learn how to quickly spin up GraphQL wrappers using the OpenAPI-to-GraphQL CLI.
52
+
-[Library tutorial](./docs/tutorials/watson.md): Learn how to use OpenAPI-to-GraphQL as a library, and how to improve the resulting GraphQL wrappers using OAS `link` definitions.
53
+
-[LoopBack tutorial](./docs/tutorials/loopback.md): Learn how to use OpenAPI-to-GraphQL to create GraphQL wrappers for APIs created with LoopBack 4.
55
54
56
55
## Characteristics
57
56
58
-
***Data-centric**
57
+
-**Data-centric**
59
58
The GraphQL interface is created around the data definitions in the given OAS, not around the endpoints, leading to a natural use of GraphQL.
60
59
61
-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/data-centric.png" alt="Example of data-centric design" width="600">
60
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/data-centric.png"alt="Example of data-centric design"width="600">
62
61
63
-
***Nested data**
64
-
[Links](https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md#linksObject) defined in the OAS are used to compose data definitions. Furthermore, hierarchical path structures can be used to nest data via the [`addSubOperations`](./packages/oasgraph/README.md#options-addsuboperations) option.
62
+
-**Nested data**
63
+
[Links](https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md#linksObject) defined in the OAS are used to compose data definitions. Furthermore, hierarchical path structures can be used to nest data via the [`addSubOperations`](./packages/openapi-to-graphql/README.md#options-addsuboperations) option.
65
64
66
-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/links.png" alt="Example of links resolution" width="600">
65
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/links.png"alt="Example of links resolution"width="600">
67
66
68
-
***Automatic query resolution**
67
+
-**Automatic query resolution**
69
68
Automatically generated resolvers translate (nested) GraphQL queries to API requests. Request results are translated back to GraphQL responses.
70
69
71
-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/resolution.png" alt="Example of query resolution" width="600">
70
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/resolution.png"alt="Example of query resolution"width="600">
72
71
73
-
***Mutations**
72
+
-**Mutations**
74
73
Non-safe, non-idempotent API operations (e.g., `POST`, `PUT`, `DELETE`) are translated to GraphQL [mutations](http://graphql.org/learn/queries/#mutations). Input payload is type-checked.
75
74
76
-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/mutations.png" alt="Example of mutation" width="600">
75
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/mutations.png"alt="Example of mutation"width="600">
77
76
78
-
***Authentication**
79
-
OASGraph currently supports authentication via API Key and basic auth. OASGraph wraps secured endpoints into a `viewer`, which takes the API key / credentials as input.
77
+
-**Authentication**
78
+
OpenAPI-to-GraphQL currently supports authentication via API Key and basic auth. OpenAPI-to-GraphQL wraps secured endpoints into a `viewer`, which takes the API key / credentials as input.
80
79
81
-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/auth.png" alt="Example of authentication" width="600">
80
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/auth.png"alt="Example of authentication"width="600">
82
81
83
-
***API Sanitation**
82
+
-**API Sanitation**
84
83
Parts of an API that not compatible with GraphQL are automatically sanitized. For example, API parameters and data definition names with unsupported characters (e.g., `-`, `.`, `,`, `:`, `;`...) are removed. GraphQL queries are desanitized to correctly invoke the REST API and the responses are resanitized to create GraphQL-compliant results.
85
84
86
-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/sanitization.png" alt="Example of sanitation" width="300">
85
+
<imgsrc="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/sanitization.png"alt="Example of sanitation"width="300">
87
86
88
-
***Custom request options** Provide headers and query parameters to send with every API request. This allows, for example, to handle authentication or tag requests from GraphQL.
89
-
90
-
***Swagger and OpenAPI 3 support** OASGraph can handle both Swagger (OpenAPI specification 2.0) as well as OpenAPI specification 3.
87
+
-**Custom request options** Provide headers and query parameters to send with every API request. This allows, for example, to handle authentication or tag requests from GraphQL.
91
88
89
+
-**Swagger and OpenAPI 3 support** OpenAPI-to-GraphQL can handle both Swagger (OpenAPI specification 2.0) as well as OpenAPI specification 3.
92
90
93
91
## Development
94
-
OASGraph uses the [Lerna](https://github.com/lerna/lerna) monorepo management system. After cloning the entire monorepo repository, you can install Lerna with the command`npm install` and then install the dependencies for all of the packages with `lerna bootstrap`.
95
92
96
-
OASGraph is written in [TypeScript](http://www.typescriptlang.org/). Within each of OASGraph's packages, all source code is contained in the `src` folder. Use `npm run build` or `npm test` to transpile the source files into the final library in the `lib` folder. Entry-point for the library is `index.js` in `lib`.
93
+
OpenAPI-to-GraphQL uses the [Lerna](https://github.com/lerna/lerna) monorepo management system. After cloning the entire monorepo repository, you can install Lerna with the command `npm install` and then install the dependencies for all of the packages with `lerna bootstrap`.
97
94
95
+
OpenAPI-to-GraphQL is written in [TypeScript](http://www.typescriptlang.org/). Within each of OpenAPI-to-GraphQL's packages, all source code is contained in the `src` folder. Use `npm run build` or `npm test` to transpile the source files into the final library in the `lib` folder. Entry-point for the library is `index.js` in `lib`.
98
96
99
97
## Research
100
-
Our research paper, "Generating GraphQL-Wrappers for REST(-like) APIs", can be found [here](https://arxiv.org/abs/1809.08319). The paper describes the challenges of building OASGraph and an experiment in which we evaluated OASGraph against 959 publicly available OAS, provided by [APIs.guru](https://apis.guru/), and successfully created GraphQL interfaces for 89.5% of them.
101
98
102
-
To run the experiment, in the [`oasgraph` package](./packages/oasgraph), load APIs.guru specifications, found [here](https://github.com/APIs-guru/openapi-directory), into the `/tmp` folder:
99
+
Our research paper, "Generating GraphQL-Wrappers for REST(-like) APIs", can be found [here](https://arxiv.org/abs/1809.08319). The paper describes the challenges of building OpenAPI-to-GraphQL and an experiment in which we evaluated OpenAPI-to-GraphQL against 959 publicly available OAS, provided by [APIs.guru](https://apis.guru/), and successfully created GraphQL interfaces for 89.5% of them.
100
+
101
+
To run the experiment, in the [`openapi-to-graphql` package](./packages/openapi-to-graphql), load APIs.guru specifications, found [here](https://github.com/APIs-guru/openapi-directory), into the `/tmp` folder:
103
102
104
103
```bash
105
104
npm run guru-load
@@ -111,15 +110,14 @@ Then, run tests:
111
110
npm run guru-test <number of APIs to test at most>
112
111
```
113
112
114
-
115
113
## Similar projects
116
114
117
-
* [swagger-to-graphql](https://github.com/yarax/swagger-to-graphql) turns a given Swagger (OpenAPI Specification 2.0) into a GraphQL interface, which resolves against the original API. GraphQL schema is based on endpoints, not on data definitions. No links are considered.
115
+
-[swagger-to-graphql](https://github.com/yarax/swagger-to-graphql) turns a given Swagger (OpenAPI Specification 2.0) into a GraphQL interface, which resolves against the original API. GraphQL schema is based on endpoints, not on data definitions. No links are considered.
118
116
119
-
* [json-to-graphql](https://github.com/aweary/json-to-graphql) turns given JSON objects / arrays into a GraphQL schema. `resolve` functions need to be provided by the user.
120
-
121
-
* [StackOverflow discussion](https://stackoverflow.com/questions/38339442/json-schema-to-graphql-schema-converters) points to the above projects.
117
+
-[json-to-graphql](https://github.com/aweary/json-to-graphql) turns given JSON objects / arrays into a GraphQL schema. `resolve` functions need to be provided by the user.
122
118
119
+
-[StackOverflow discussion](https://stackoverflow.com/questions/38339442/json-schema-to-graphql-schema-converters) points to the above projects.
The purpose of this tutorial is to show how easy it is to use OASGraph CLI in combination with LoopBack.
3
+
The purpose of this tutorial is to show how easy it is to use OpenAPI-to-GraphQL CLI in combination with LoopBack.
4
4
5
-
With just a single command line instruction, `oasgraph <OAS JSON file path or remote url>`, you can get a GraphQL server running.
5
+
With just a single command line instruction, `openapi-to-graphql <OAS JSON file path or remote url>`, you can get a GraphQL server running.
6
6
7
-
Please note that while the CLI tool will satisfy most needs, it does not offer the flexibility or functionality of OASGraph's intended usage, as an integrated library. See the [README.md](../../README.md) for more information.
7
+
Please note that while the CLI tool will satisfy most needs, it does not offer the flexibility or functionality of OpenAPI-to-GraphQL's intended usage, as an integrated library. See the [README.md](../../README.md) for more information.
8
8
9
9
## Video demo
10
10
11
-
[](https://www.youtube.com/watch?v=KXUTmM6y-LM"Click here to watch!")
11
+
[](https://www.youtube.com/watch?v=KXUTmM6y-LM"Click here to watch!")
12
12
13
13
## Do it yourself
14
14
15
15
### Make sure you have installed Node.js
16
16
17
-
Before you install OASGraph, make sure to download and install Node.js (version 8.9.x or higher), a JavaScript runtime.
17
+
Before you install OpenAPI-to-GraphQL, make sure to download and install Node.js (version 8.9.x or higher), a JavaScript runtime.
18
18
19
19
To install Node.js, click [here](https://nodejs.org/en/download/).
20
20
21
-
### Install OASGraph
21
+
### Install OpenAPI-to-GraphQL
22
22
23
-
OASGraph can be used either as a library, or via its Command Line Interface (CLI). To install the CLI tool, run the following command.
23
+
OpenAPI-to-GraphQL can be used either as a library, or via its Command Line Interface (CLI). To install the CLI tool, run the following command.
24
24
25
25
```sh
26
-
npm i -g oasgraph-cli
26
+
npm i -g openapi-to-graphql-cli
27
27
```
28
28
29
29
### Save or locate the OAS
30
30
31
-
OASGraph relies on the OpenAPI Specification (OAS) of an existing API to create a GraphQL interface around that API. OASGraph can also retrieve a web-hosted OAS.
31
+
OpenAPI-to-GraphQL relies on the OpenAPI Specification (OAS) of an existing API to create a GraphQL interface around that API. OpenAPI-to-GraphQL can also retrieve a web-hosted OAS.
32
32
33
33
If you are using LoopBack, you can simply copy the URL location of the web-hosted OAS, which should be located at http://127.0.0.1:3000/openapi.json after starting the API.
34
34
@@ -43,10 +43,10 @@ If you want to generate a GraphQL interface for another API, make sure that API
43
43
44
44
### Start GraphQL server
45
45
46
-
Once OASGraph is installed and the OAS is obtained, you can create and start the GraphQL server. The created GraphQL server is then accessible by default at [http://127.0.0.1:3001/graphql](http://127.0.0.1:3001/graphql).
46
+
Once OpenAPI-to-GraphQL is installed and the OAS is obtained, you can create and start the GraphQL server. The created GraphQL server is then accessible by default at [http://127.0.0.1:3001/graphql](http://127.0.0.1:3001/graphql).
47
47
48
48
You can specify a local file containing the OAS specification or a remote url such as `http://127.0.0.1:3000/openapi.json`.
49
49
50
50
```sh
51
-
oasgraph<OAS JSON file path or remote url>
51
+
openapi-to-graphql<OAS JSON file path or remote url>
0 commit comments