Skip to content

Latest commit

 

History

History
101 lines (77 loc) · 3.42 KB

Commands.md

File metadata and controls

101 lines (77 loc) · 3.42 KB

Commands

List of available commands

init, -i

Provides an easy way to create a GraphQL server based on @entria/graphql-dataloader-boilerplate which is a production-ready server

We are currently using the same boilerplate on three applications running on production at @entria

create-graphql init GraphQLProject

Creates a new GraphQL project. The project contains the following structure:

├── /data/                   # GraphQL generated schema
├── /repl/                   # Read-Eval-Print-Loop (REPL) configuration
├── /scripts/                # Generate GraphQL schema script
├── /src/                    # Source code of GraphQL Server
│   ├── /connection/         # Connections types (Relay)
│   ├── /interface/          # NodeInterface (Relay)
│   ├── /loader/             # Loaders of the models using DataLoader
│   ├── /model/              # Models definition (Mongoose, SQL, Google DataStore)
│   ├── /mutation/           # Mutations definition
├── /test/                   # Test helpers

generate, -g

Generates the files by passing these options:

--type, -t

Creates a type file and it's name will be automatically suffixed with Type

create-graphql generate --type Story

Generates StoryType file under the path ./src/type

--mutation, -m

Creates mutations, the files names will be automatically suffixed with Mutation

create-graphql generate --mutation Story

Generates StoryAddMutation and StoryEditMutation under the path ./src/mutation

Hint: To generates mutations based on a Mongoose schema, use --schema option

create-graphql generate --mutation Story --schema Story

Which will look for Story Mongoose schema file in ./src/model and generate the mutations fields based on it

Hint: you may use aliases commands to create multiple files in one single command:

create-graphql generate -tm Story --schema Story

Will create a GraphQL type and mutation based on Story schema and automatically generated tests using Jest

--loader, -l

Creates a GraphQL loader, the files names will be automatically suffixed with Loader

create-graphql generate --loader Story

Generates a StoryLoader file importing StoryConnection under the path ./src/loader

--connection, -c

Creates a Relay connection, the files names will be automatically suffixed with Connection

create-graphql generate --connection Story

Generates a StoryConnection importing StoryType under the path ./src/connection

--help, -h

Output usage information with all available commands

--version, -V

Output the current version

If yout need, you can update Create-GraphQL with:

yarn global upgrade create-graphql # Also works with NPM as `npm update --global create-graphql`