A plugin to create custom REST-like APIs from GraphQL APIs
Last updated 2 years ago by fosrias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install apiql-express 
SYNC missed versions from official npm registry.

APIQL Express

Giving API consumers the power of REST resources for GraphQL APIs.

apiql-express is a light express module that can be used in a proxy or a gateway in front of any GraphQL service, or in a Node.js-based GraphQL service to enable consumers to create any number of ad hoc REST resources using GraphQL queries and mutations as the configuration language.

Work-in-progress - POC at this point, subject to lots of change

  • No tests yet
  • No permenant persistence yet

Quick Start

You can try out out the proxy example with the Star Wars example server and the proxy example as follows:

In one terminal:

$ git clone git@github.com:apollographql/starwars-server.git
$ cd starwars-server
$ npm install
$ npm start

And in another terminal:

$ git clone git@github.com:fosrias/apiql-express.git
$ cd apiql-express/examples/proxy
$ npm install
$ npm start
$ open http://apiql/description

And in another terminal:

$ cd path/to/project/root
$ curl --header "Content-Type: application/openapi+yaml" \                                                                       2 ↵
  --request PUT \
  --data "$(cat examples/star-wars-api.yml)" \
$ curl localhost:3000/droids/2000
$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ "review": {"stars": 5, "commentary": "This is a great movie!" }}' \
$ open http://localhost:3000/apiql/apis/my-api


Creating ad hoc APIs

Basically, following API design-first principles, you would define an OpenAPI 3.0 Description document for your REST API. Currently, the response are un-transformed GraphQL responses, so if you want to add components, they need be the GraphQL responses. Then, if you want to add a query or mutation, add a x-graphqlQuery or x-graphQLMutation string, respectively, to each opertion in the description document. The operationId MUST match the query method name and any operation parameter names must exactly match any of the GraphQL $ $parameters. That's it.

      description: Returns a Droid
      operationId: droidById
      - name: id
        in: path
        description: ID of a droid to fetch
        required: true
          type: integer
          format: int64
      x-graphqlQuery: |
        query droidById($id: ID!) {  
          droid(id: $id) {



Thanks to Stephen Mizell for lots of good thoughts.

Current Tags

  • 0.0.1                                ...           latest (2 years ago)

1 Versions

  • 0.0.1                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (8)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |