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.
Play with API
This project is currently running on Heroku at warthog-starter.herokuapp.com/graphql. Feel free to play around with it.
To get things set up in development, where everything will run in
Running the server
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.
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:
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:
Generating a new resource
To generate a new
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 (
authorabove) 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)
datatypemust be one of the following:
datatypeis missing, it's assumed to be