A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/IBM/openapi-to-graphql below:

IBM/openapi-to-graphql: Translate APIs described by OpenAPI Specifications (OAS) into GraphQL

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:

  1. Install the OpenAPI-to-GraphQL CLI using:
    npm i -g openapi-to-graphql-cli
  2. Then, run the OpenAPI-to-GraphQL command and point it to an OpenAPI Specification:
    openapi-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.

  1. Install OpenAPI-to-GraphQL as a dependency:
    npm i -s openapi-to-graphql
  2. Require OpenAPI-to-GraphQL and use the createGraphQLSchema function:
    const { createGraphQLSchema } = require("openapi-to-graphql");
    // load or construct OAS (const oas = ...)
    const { 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:

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:

Then, run tests:

npm run guru-test <number of APIs to test at most>

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4