Skip to content

gabrielbusarello/gb-graphql-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL CLI

A Command Line interface for GraphQL applications.

GitHub forks GitHub stars

GitHub license

Usage

Installation

npm install -g gb-graphql-cli

Running gb-graphql-cli --help

Usage: gb-graphql-cli [options] [command]

Options:

  -v, --version              output the version number
  -h, --help                 output usage information

Commands:

  init [options] <projname>  Init the GraphQL project
  run                        Start the development server
  create <schema> <name>     Create files based on a schematic. Possible schemas: (model, resource)

Examples:
   gb-graphql-cli init helloWorld
   gb-graphql-cli init helloWorld -d mssql
   gb-graphql-cli init helloWorld -a
   gb-graphql-cli run
   gb-graphql-cli create model example

How to Use - Initializing a new GraphQL project

Assuming that you have installed the cli, follow the steps below for run your first application.

  1. The first step, is initialize the project:
gb-graphql-cli init helloWorld
# If you are using another DBMS, you can set like that:
# Possible values: (mysql, mssql, sqlite, postgres)
gb-graphql-cli init helloWorld --dialect mssql
  1. Don't forget that you have to change the JWT_SECRET in package.json.
  2. After the initialization finishes, you have to start your database service and create a database named "helloWorld".
  3. With database service started, go to config.json file, located in "helloWorld/src/config/config.json".
  4. Change the "database" key, of key "development" to the name "helloWorld".
{
    "development": {
        "username": "root",
        "password": null,
        "database": "helloWorld",
        "host": "127.0.0.1",
        "dialect": "mysql"
    },
    "test": {
        "username": "root",
        "password": null,
        "database": "database_test",
        "host": "127.0.0.1",
        "dialect": "mysql"
    },
    "production": {
        "username": "root",
        "password": null,
        "database": "database_production",
        "host": "127.0.0.1",
        "dialect": "mysql"
    }
}
  1. Now it's time to run the application. Go to main of your project and type gb-graphql-cli run.
  2. Wait for the build and the nodemon server being ready.
  3. Access localhost:3000/graphql. As this application is from GraphQL, just have one end-point. In development environment, accessing this end-point in browser you will see the GraphiQL interface.
  4. Now you can create mutations and queries for the ExampleModel.
  5. Enjoy!

About

Graphql's CLI!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published