Skip to content

Commit f981947

Browse files
Alan-ChaErikWittern
authored andcommitted
Rename repository
Signed-off-by: Alan Cha <[email protected]>
1 parent a9576ae commit f981947

File tree

119 files changed

+2430
-2471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2430
-2471
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
1-
# Contributing to OASGraph
1+
# Contributing to OpenAPI-to-GraphQL
22

3-
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.
54

65
### Developer Certificate of Origin
76

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.
128

139
> By making a contribution to this project, I certify that:
1410
>
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
1812
>
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
2614
>
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.
3016
>
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.
3618
3719
Contributors sign-off that they adhere to these requirements by adding a Signed-off-by line to commit messages.
3820

@@ -56,14 +38,14 @@ If you've pushed a commit and forgot to sign it, fear not, you can sign it as fo
5638
git commit --amend -s
5739
```
5840

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`).
6042

6143
Now force-push the changes by running:
44+
6245
```
6346
git push origin +[branch-name]
6447
```
6548

6649
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.
6750

6851
If all else fails, ask the LoopBack team for help :)
69-

README.md

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,104 +2,103 @@
22
![Travis (.org)](https://img.shields.io/travis/strongloop/oasgraph.svg?style=flat)
33
[![Join the chat at https://gitter.im/oasgraph/Lobby](https://badges.gitter.im/oasgraph/Lobby.svg?style=flat)](https://gitter.im/oasgraph/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

5+
# OpenAPI-to-GraphQL
56

6-
# OASGraph
77
Translate APIs described by [OpenAPI Specifications (OAS)](https://github.com/OAI/OpenAPI-Specification) into [GraphQL](https://graphql.org/).
88

9-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/translation.png" alt="Overview of translation" width="600">
10-
9+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/translation.png" alt="Overview of translation" width="600">
1110

1211
## Getting started
13-
OASGraph can be used in two ways:
1412

13+
OpenAPI-to-GraphQL can be used in two ways:
1514

1615
### CLI
17-
The Command Line Interface (CLI) provides a convenient way to start a GraphQL server wrapping an API for a given OpenAPI Specification:
1816

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:
2718

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+
```
2927

28+
For further details, refer to the [`openapi-to-graphql-cli` documentation](./packages/openapi-to-graphql-cli).
3029

3130
### Library
32-
Use OASGraph as a library in your application to generate GraphQL schemas.
3331

34-
1. Install OASGraph as a dependency:
35-
```bash
36-
npm i -s oasgraph
37-
```
38-
2. Require OASGraph and use the `createGraphQlSchema` function:
39-
```javascript
40-
const { createGraphQlSchema } = require('oasgraph')
41-
// load or construct OAS (const oas = ...)
42-
const { schema, report } = await createGraphQlSchema(oas)
43-
```
32+
Use OpenAPI-to-GraphQL as a library in your application to generate GraphQL schemas.
4433

45-
For further details, refer to the [`oasgraph` documentation](./packages/oasgraph).
34+
1. Install OpenAPI-to-GraphQL as a dependency:
35+
```bash
36+
npm i -s openapi-to-graphql
37+
```
38+
2. Require OpenAPI-to-GraphQL and use the `createGraphQlSchema` function:
39+
```javascript
40+
const { createGraphQlSchema } = require("openapi-to-graphql");
41+
// load or construct OAS (const oas = ...)
42+
const { schema, report } = await createGraphQlSchema(oas);
43+
```
4644

45+
For further details, refer to the [`openapi-to-graphql` documentation](./packages/openapi-to-graphql).
4746

4847
## Tutorials
49-
Here are some guides to further help you get started:
5048

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:
5450

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.
5554

5655
## Characteristics
5756

58-
* **Data-centric**
57+
- **Data-centric**
5958
The GraphQL interface is created around the data definitions in the given OAS, not around the endpoints, leading to a natural use of GraphQL.
6059

61-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/data-centric.png" alt="Example of data-centric design" width="600">
60+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/data-centric.png" alt="Example of data-centric design" width="600">
6261

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.
6564

66-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/links.png" alt="Example of links resolution" width="600">
65+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/links.png" alt="Example of links resolution" width="600">
6766

68-
* **Automatic query resolution**
67+
- **Automatic query resolution**
6968
Automatically generated resolvers translate (nested) GraphQL queries to API requests. Request results are translated back to GraphQL responses.
7069

71-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/resolution.png" alt="Example of query resolution" width="600">
70+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/resolution.png" alt="Example of query resolution" width="600">
7271

73-
* **Mutations**
72+
- **Mutations**
7473
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.
7574

76-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/mutations.png" alt="Example of mutation" width="600">
75+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/mutations.png" alt="Example of mutation" width="600">
7776

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.
8079

81-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/auth.png" alt="Example of authentication" width="600">
80+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/auth.png" alt="Example of authentication" width="600">
8281

83-
* **API Sanitation**
82+
- **API Sanitation**
8483
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.
8584

86-
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/master/docs/sanitization.png" alt="Example of sanitation" width="300">
85+
<img src="https://raw.githubusercontent.com/strongloop/oasgraph/openapi-to-graphql/docs/sanitization.png" alt="Example of sanitation" width="300">
8786

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.
9188

89+
- **Swagger and OpenAPI 3 support** OpenAPI-to-GraphQL can handle both Swagger (OpenAPI specification 2.0) as well as OpenAPI specification 3.
9290

9391
## 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`.
9592

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`.
9794

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`.
9896

9997
## 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.
10198

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:
103102

104103
```bash
105104
npm run guru-load
@@ -111,15 +110,14 @@ Then, run tests:
111110
npm run guru-test <number of APIs to test at most>
112111
```
113112

114-
115113
## Similar projects
116114

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.
118116

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.
122118

119+
- [StackOverflow discussion](https://stackoverflow.com/questions/38339442/json-schema-to-graphql-schema-converters) points to the above projects.
123120

124121
## License
125-
[MIT](./LICENSE.md)
122+
123+
[MIT](./LICENSE.md)

docs/tutorials/cli_loopback.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# OASGraph Quickstart tutorial
1+
# OpenAPI-to-GraphQL Quickstart tutorial
22

3-
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.
44

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.
66

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.
88

99
## Video demo
1010

11-
[![OASGraph](../conveyor_belt.png)](https://www.youtube.com/watch?v=KXUTmM6y-LM "Click here to watch!")
11+
[![OpenAPI-to-GraphQL](../conveyor_belt.png)](https://www.youtube.com/watch?v=KXUTmM6y-LM "Click here to watch!")
1212

1313
## Do it yourself
1414

1515
### Make sure you have installed Node.js
1616

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.
1818

1919
To install Node.js, click [here](https://nodejs.org/en/download/).
2020

21-
### Install OASGraph
21+
### Install OpenAPI-to-GraphQL
2222

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.
2424

2525
```sh
26-
npm i -g oasgraph-cli
26+
npm i -g openapi-to-graphql-cli
2727
```
2828

2929
### Save or locate the OAS
3030

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.
3232

3333
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.
3434

@@ -43,10 +43,10 @@ If you want to generate a GraphQL interface for another API, make sure that API
4343

4444
### Start GraphQL server
4545

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).
4747

4848
You can specify a local file containing the OAS specification or a remote url such as `http://127.0.0.1:3000/openapi.json`.
4949

5050
```sh
51-
oasgraph <OAS JSON file path or remote url>
51+
openapi-to-graphql <OAS JSON file path or remote url>
5252
```

0 commit comments

Comments
 (0)