GraphQL-Express-App CLI — A New Way to Learn and Build GraphQL APIs

Yash Garudkar
Level Up Coding
Published in
3 min readAug 11, 2020

--

Photo by Debby Hudson on Unsplash

Hey guys, if you are new to OSS(open source software) development and want to get started with open source contributions, then here is the organization for you where you can initiate your projects and contribute to previously started projects too!

Ping me on Twitter if you would like to start a Project in QuBytes-OSS!

Organization Link: https://github.com/QuBytes-OSS

I have been using GraphQL to learn and build some personal projects. And in the process, I needed some boilerplate to a new project.

It inspired me to start working on something that would fasten the process of starting a new project. Something that enables anyone to build a GraphQL-Express server with a MongoDB database with ease.

So, I built the graphql-express-app CLI tool that can be used by anyone to start their new GraphQL-Express project with a MongoDB database.

Features:

  1. Command Line Interface for faster project generation.
  2. Initialize Git from the CLI.
  3. Install dependencies from CLI.
  4. TypeScript Support (Coming Soon!)

What is graphql-express-app CLI?

It is a CLI (command line interface) to start a GraphQL-Express server with some pre-designed MongoDB model for handling database and a Schema to access the Database and carry out GraphQL queries and mutations.

What to expect from the CLI?

The CLI will lead you to create a simple GraphQL-Express app that you can further build according to your project needs.

What are the dependencies in the generated project?

This CLI is built to initialize a GraphQL-Express server. It uses the following dependencies for starting a new project.

  • graphql: To build a GraphQL schema and design GraphQL types and use them for creating queries and mutations.
  • express: It is an npm module used to build routes in back-end applications and create middleware functions.
  • express-graphql: it helps us create a GraphQL HTTP server in the Express routes as a middleware function.
  • graphql-type-long: GraphQL doesn’t have a predefined long-integer type. This npm module helps bridge that gap.
  • dotenv: used to store MongoDB URI.
  • mongoose: used to connect to the MongoDB database and carry out CRUD functions.

How to use the graphql-express-app CLI?

Make sure to have the latest Node.js version installed and MongoDB for database.

1. Use the following command to install the graphql-express-app CLI globally on your machine:

$ npm i -g graphql-express-app

2. Create a folder according to your desired name and open the same:

$ mkdir folder_name && cd folder_name

3. Run the following command in the shell:

[yolo@localhost folder_name]$ graphql-express-app

4. Follow the questions and answer the options.

5. Make sure to have a MongoDB installed on your machine or have an online MongoDB instance and change .env variable in the project accordingly.

Voila! You have successfully created a GraphQL-Express App!

TypeScript Support

I am currently working on TypeScript support for the CLI. Soon enough we will release the version with TypeScript support.

Hope you like this project and make use of it in your future projects ❤

Happy coding!

Repository for the project:

Give it a star if you will use this tool for your projects😊

--

--