Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rmoorman/graphql-starter-kit

 
 

Repository files navigation

GraphQL Starter Kit  

Project template for authoring GraphQL server applications with Node.js 7+ and JavaScript (demo). You can use it either as a playground or a base for your next Node.js-based backend project.

Directory Layout

.
├── /build/                     # The compiled output (via Babel)
├── /migrations/                # Database schema migrations
├── /node_modules/              # Project dependencies (npm modules)
├── /scripts/                   # Build automation scripts
├── /src/                       # Node.js application source files
│   ├── /db/                    # Database access methods and connection pooling
│   ├── /passport/              # Passport.js authentication strategies
│   ├── /routes/                # Express routes, e.g. /login/facebook
│   ├── /types/                 # GraphQL types /w resolve functions
│   │   ├── /User.js            # User account (id, email, etc.)
│   │   ├── /Viewer.js          # The top-level GraphQL object type
│   │   └── /...                # etc.
│   ├── /utils/                 # Utility functions
│   ├── /app.js                 # Express application
│   ├── /schema.js              # GraphQL schema
│   └── /server.js              # Node.js server (entry point)
├── /test/                      # Unit, integration and load tests
├── .env                        # Application settings for the dev environment
├── package.json                # The list of project dependencies
└── yarn.lock                   # Fixed versions of all the dependencies

Prerequisites

Getting Started

Just clone the repo and start hacking:

git clone -o graphql-starter-kit -b master --single-branch \
   https://github.com/kriasoft/graphql-starter-kit.git api.example.com
cd api.example.com
yarn install                    # Install project dependencies. Alternatively, npm install
npm run db:create               # Create a new database (see .env/DATABASE_URL)
npm run db:migrate              # Migrate database schema to the latest version
npm run start                   # Launch the app. Alternatively, node scripts/start.js

The GraphQL server should become available at http://localhost:5000/ (live demo).

If you just need to build the project without launching a dev server, run one of these two commands:

npm run build                   # Compiles the app into the /build folder
npm run build:watch             # Compiles the app and starts watching for changes

Database

The following scripts can be used to transfer your existing database into another state and vise versa. Those state transitions are saved in migration files (/migrations/*.js), which describe the way how to get to the new state and how to revert the changes in order to get back to the old state.

npm run db:create               # Create a new database
npm run db:drop                 # Drop the database
npm run db:version              # Print database schema version
npm run db:migrate              # Migrate database schema to the latest version
npm run db:migrate:undo         # Rollback the latest migration
npm run db:migration <name>     # Create a new migration from the template (see /migrations folder)
npm run db:seed                 # Import reference data

Testing

npm run lint                    # Find problematic patterns in code
npm run check                   # Check source code for type errors
npm run test                    # Run unit tests once
npm run test:watch              # Run unit tests in watch mode

Debugging

# Option 1:
npm run build && node build/server.js --debug --nolazy

# Option 2:
npm run start -- --debug --nolazy

After launching the app in a debug mode attach your debugger to the process listening on 127.0.0.1:5858.

Contributing

Anyone and everyone is welcome to contribute. Start by checking out the list of open issues marked help wanted. However, if you decide to get involved, please take a moment to review the guidelines:

Related Projects

Support

License

Copyright © 2016-present Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.


Made with ♥ by Konstantin Tarkus (@koistya) and contributors

About

Project template for authoring GraphQL server applications with Node.js 7 and JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%