Skip to content
Warthog GraphQL API minimal sample application
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
.vscode
db/migrations
docs
generated
img
src
test
tools
.eslintignore
.eslintrc.js
.gitignore
.nvmrc
.prettierignore
LICENSE
Procfile
README.md
env.yml
nodemon.json
package.json
tsconfig.json
warthog.config.js
yarn.lock

README.md

Warthog Logo

This is a minimal example of using the (Warthog GraphQL API library. Warthog is a Node.js GraphQL Framework for building APIs with strong conventions through auto-generated code. With Warthog, set up your data models and resolvers, and it does the rest.

CircleCI styled with prettier Join the chat at https://gitter.im/warthog-graphql/community

Play with API

This project is currently running on Heroku at warthog-starter.herokuapp.com/graphql. Feel free to play around with it.

Development Setup

To get things set up in development, where everything will run in ts-node, run yarn bootstrap.

Running the server

Run yarn build:dev && yarn start:dev to run the server.

Using GraphQL Playground

When you run yarn start:dev, it will open graphql-playground. When in the playground, you can issue queries and mutations against the API.

Running tests

Run yarn test to run tests

Running in Production Mode

In Production mode, you'll need to build and run the compiled code. To do this locally, run:

yarn start

Generating Migrations

When you're ready to check in your feature, you'll need to generate a DB migration. This can automatically be done by running:

yarn db:migrate:generate user-and-post

This will drop a migration in the db folder. To run it and create the schema in your DB, run:

yarn db:migrate

Generating a new resource

To generate a new model, service and resolver, run warthog generate <model-name>. So for example:

warthog generate like

...or if you want to bootstrap with some fields:

warthog generate author name! nickname numLogins:int! verified:bool! registeredAt:date balance:float!

Some notes about this format:

  • First param (author above) is always the resource name (required)
  • Each subsequent item is a separate field/column that will be added to the model
  • The format is fieldName:datatype, with an optional ! at the end to mark the field required and non-nullable (otherwise it's optional)
  • datatype must be one of the following: bool, date, int, float, string
  • If datatype is missing, it's assumed to be string
You can’t perform that action at this time.