trailpack-graphql
This is a draft proposal
This trailpack provides a Relay-compatible GraphQL implementation for Trails.
Install
$ npm install --save trailpack-graphql
Configure
// config/main.jsmoduleexports = packs: // ... other trailpacks
Usage
Define Models
User
model
static { return graphql` type User { id: ID! email: String! age: Int role: Role! } type Query { user (email: String): User allUsers (): [User] } ` } static { return { // find user by email } }
Role
model
static { return graphql` type Role { name: String! users: [User] } type Query { userRoles (id: ID!): [Role] } ` } static { { // select roles from role where role.user_id = userId } }
References
-
Spec and Schema
-
Querying
-
Mutations