Skip to content
Branch: master
Find file History
Alan-Cha Publish
 - openapi-to-graphql-cli@1.2.0
 - openapi-to-graphql@1.2.0
Latest commit f6f08a2 Jul 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Fix CLI remote YAML bug Jul 12, 2019
src Fix CLI remote YAML bug Jul 12, 2019
.prettierignore Capitalize comments Jun 20, 2019
.prettierrc Rename repository Jun 20, 2019 Rename repository Jun 20, 2019 Categorize options Jul 10, 2019
package.json Publish Jul 12, 2019
tsconfig.json Prettier JSON files Jun 20, 2019

Travis (.org) npm Join the chat at

OpenAPI-to-GraphQL CLI

Command line interface (CLI) for turning APIs described by OpenAPI Specification (OAS) into GraphQL interfaces.

Overview of translation

Note: To use OpenAPI-to-GraphQL as a library, refer to the openapi-to-graphql package.


npm i -g openapi-to-graphql-cli


Usage: openapi-to-graphql <OAS JSON file path(s) and/or remote url(s)> [options]

  -V, --version                output the version number
  -s, --strict                 throw an error if OpenAPI-to-GraphQL cannot run without compensating for errors or missing data in the OAS
  --save <file path>           save schema to path and do not start server

  -p, --port <port>            select the port where the server will start
  -u, --url <url>              select the base url which paths will be built on
  --cors                       enable Cross-origin resource sharing (CORS)

  -o, --operationIdFieldNames  create field names based on the operationId
  -f, --fillEmptyResponses     create placeholder schemas for operations with no response body rather than ignore them
  -a, --addLimitArgument       add a limit argument on fields returning lists of objects/lists to control the data size

  --no-viewer                  do not create GraphQL viewer objects for passing authentication credentials
  --no-extensions              do not add extentions, containing information about failed REST calls, to the GraphQL errors objects
  --no-equivalentToMessages    do not append information about the underlying REST operations to the description of fields
  -h, --help                   output usage information

The basic usage of the CLI takes the specified OAS, creates a GraphQL interface for it, and starts a server to host the GraphQL interface.

openapi-to-graphql oas.json

You can also create a GraphQL interface using multiple OASs.

openapi-to-graphql oas.json oas2.json oas3.json

You can specify the OAS by pointing to either a local file or a remote url such as Additionally, you can specify a port number so you can have multiple GraphQL servers running on the same machine.

openapi-to-graphql -p 3001

OpenAPI-to-GraphQL can also save a GraphQL schema to a local file, which you can use to inspect or change its content. Please note that the following command will not start the GraphQL server.

openapi-to-graphql oas.json --save schema.graphql

To learn more about the other options, please refer here.

Please note that the CLI tool is mainly used for quick testing and does not offer all the features that createGraphQlSchema(oas, options) does.



You can’t perform that action at this time.