Gathering detailed insights and metrics for openapi-to-graphql
Gathering detailed insights and metrics for openapi-to-graphql
Gathering detailed insights and metrics for openapi-to-graphql
Gathering detailed insights and metrics for openapi-to-graphql
openapi-to-graphql-cli
CLI for turning APIs described by OpenAPI Specifications (OAS) into GraphQL interfaces
openapi-to-graphql-nullable
Fork of openapi-to-graphql that fixes nullable handling. Published to NPM since there's no other easy way to consume a Lerna package. Unmaintained.
openapi-typescript
Convert OpenAPI 3.0 & 3.1 schemas to TypeScript
graphql
A Query Language and Runtime which can target any service.
npm install openapi-to-graphql
OpenAPI-to-GraphQL v2.6.3
Published on 04 Feb 2022
OpenAPI-to-GraphQL v2.6.2
Published on 03 Feb 2022
OpenAPI-to-GraphQL v2.6.1
Published on 18 Jan 2022
OpenAPI-to-GraphQL v2.6.0
Published on 15 Dec 2021
OpenAPI-to-GraphQL v2.5.2
Published on 28 Nov 2021
OpenAPI-to-GraphQL v2.5.1
Published on 31 Jul 2021
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,612 Stars
685 Commits
211 Forks
39 Watching
2 Branches
45 Contributors
Updated on 25 Nov 2024
TypeScript (89.29%)
JavaScript (10.71%)
Cumulative downloads
Total Downloads
Last day
-0.2%
6,603
Compared to previous day
Last week
11.7%
32,249
Compared to previous week
Last month
-4.5%
125,617
Compared to previous month
Last year
2.3%
1,465,550
Compared to previous year
17
1
33
Translate APIs described by OpenAPI Specifications (OAS) or Swagger into GraphQL.
OpenAPI-to-GraphQL can be used in two ways:
The Command Line Interface (CLI) provides a convenient way to start a GraphQL server wrapping an API for a given OpenAPI Specification:
1npm i -g openapi-to-graphql-cli
1openapi-to-graphql <OAS JSON file path or remote url> [options]
For further details, refer to the openapi-to-graphql-cli
documentation.
Use OpenAPI-to-GraphQL as a library in your application to generate GraphQL schemas.
1npm i -s openapi-to-graphql
createGraphQLSchema
function:
1const { createGraphQLSchema } = require("openapi-to-graphql"); 2// load or construct OAS (const oas = ...) 3const { schema, report } = await createGraphQLSchema(oas);
For further details, refer to the openapi-to-graphql
documentation.
Here are some guides to further help you get started:
link
definitions.Data-centric The GraphQL interface is created around the data definitions in the given OAS, not around the endpoints, leading to a natural use of GraphQL.
Nested data Links defined in the OAS are used to create nested data structures, allowing for (deeply) nested queries.
Automatic query resolution Automatically generated resolvers translate (nested) GraphQL queries to API requests. Request results are translated back to GraphQL responses.
Mutations
Non-safe, non-idempotent API operations (e.g., POST
, PUT
, DELETE
) are translated to GraphQL mutations. Input payload is type-checked.
Subscriptions
GraphQL subscriptions allow clients to receive a stream of events, such as updates whenever data changes on the GraphQL server. OpenAPI-to-GraphQL can create subscriptions based on callback
objects defined in the OAS.
Authentication
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.
API Sanitation
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.
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.
Swagger and OpenAPI 3 support OpenAPI-to-GraphQL can handle both Swagger (OpenAPI specification 2.0) as well as OpenAPI specification 3.
OpenAPI-to-GraphQL is written in TypeScript. Within each of OpenAPI-to-GraphQL's packages, all source code is contained in the src
folder. Use yarn build
or yarn test
to transpile the source files into the final library in the dist
folder. Entry-point for the library is index.js
in dist
.
Our research paper, "Generating GraphQL-Wrappers for REST(-like) APIs", can be found here. 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, and successfully created GraphQL interfaces for 89.5% of them.
To run the experiment, in the openapi-to-graphql
package, load APIs.guru specifications, found here, into the /tmp
folder:
1npm run guru-load
Then, run tests:
1npm run guru-test <number of APIs to test at most>
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.
json-to-graphql turns given JSON objects / arrays into a GraphQL schema. resolve
functions need to be provided by the user.
StackOverflow discussion points to the above projects.
No vulnerabilities found.
Reason
no vulnerabilities detected
Reason
license file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 7
Details
Reason
GitHub code reviews found for 11 commits out of the last 30 -- score normalized to 3
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
0 commit(s) out of 30 and 0 issue activity out of 30 found in the last 90 days -- score normalized to 0
Reason
no badge detected
Reason
non read-only tokens detected in GitHub workflows
Details
Reason
security policy file not detected
Reason
project is not fuzzed
Reason
no update tool detected
Details
Score
Last Scanned on 2022-08-15
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More