The goal of this guide is to generate a GraphQL API on top of a lumber-based application using the plugin lumber-graphql.
A Lumber-based application. Check out this guide if you don't have one yet.
First, ensure to start your docker container by typing
docker-compose up from your application's directory.
$ docker-compose upStarting MySuperApp ... doneAttaching to MySuperAppMySuperApp |MySuperApp | > MySuperApp@0.0.1 start /usr/src/appMySuperApp | > node ./bin/wwwMySuperApp |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/bashroot@443d5ba2f89a:/usr/src/app#
$ 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
> 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 upKilling MySuperApp ... done$ docker-compose upStarting MySuperApp ... doneAttaching to MySuperAppMySuperApp |MySuperApp | > MySuperApp@0.0.1 start /usr/src/appMySuperApp | > node ./bin/wwwMySuperApp |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.
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".
For each table, a