Installation

1. Goals

The goal of this guide is to generate a GraphQL API on top of a lumber-based application using the plugin lumber-graphql.

Prerequisites

2. Connecting to the container

First, ensure to start your docker container by typing docker-compose up from your application's directory.

$ docker-compose up
Starting MySuperApp ... done
Attaching to MySuperApp
MySuperApp |
MySuperApp | > MySuperApp@0.0.1 start /usr/src/app
MySuperApp | > node ./bin/www
MySuperApp |
MySuperApp | Your application is listening on port 3000.

Finally, open a new tab in your terminal and type docker run -ti <container_name> /bin/bash to enter to the container with a bash shell instantiated.

$ docker exec -ti MySuperApp /bin/bash
root@443d5ba2f89a:/usr/src/app#

3. Install the GraphQL plugin

We just need to install the lumber-graphql plugin using NPM.

$ npm install lumber-graphql --save

Then, we have to use the lumber install command to execute the install logic implemented in the plugin. To do so, just type:

$ lumber install lumber-graphql

In this case, the install method generates a Lumber middleware located under the directory middlewares/graphql . In this directory, the index.js file is responsible to load the GraphQL schemas and resolvers automatically generated under the directory graphql/.

> Hooray, installation success!
> install dependencies:
$ npm install apollo-server-express graphql graphql-iso-date graphql-type-json --save

Last but not least, we have to install the last dependencies required by the plugin as requested. So, just type the following npm install command.

npm install apollo-server-express graphql graphql-iso-date graphql-type-json --save

Finally, we have to restart our container by hitting CTRL+C from your host machine.

$ docker-compose up
Killing MySuperApp ... done
$ docker-compose up
Starting MySuperApp ... done
Attaching to MySuperApp
MySuperApp |
MySuperApp | > MySuperApp@0.0.1 start /usr/src/app
MySuperApp | > node ./bin/www
MySuperApp |
MySuperApp | Your application is listening on port 3000.

From this step, you should see the GraphQL plugin listed in the welcome page at http://localhost:3000.

4. Discover your GraphQL API

A GraphQL playground interface is available at http://localhost:3000/graphql.

The entire schema description can be found on the right side on the screen after clicking on the "Schema" button".

Queries

List records

For each table, a list_<tableName>