# trailpack-graphql **Repository Path**: mirrors_codejamninja/trailpack-graphql ## Basic Information - **Project Name**: trailpack-graphql - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2025-09-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # trailpack-graphql [![NPM version][npm-image]][npm-url] [![Build status][ci-image]][ci-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Code Climate][codeclimate-image]][codeclimate-url] ## This is a draft proposal This trailpack provides a [Relay-compatible](https://facebook.github.io/relay/docs/graphql-relay-specification.html) GraphQL implementation for [Trails](http://trailsjs.io). ## Install ```sh $ npm install --save trailpack-graphql ``` ### Configure ```js // config/main.js module.exports = { packs: [ // ... other trailpacks require('trailpack-graphql') ] } ``` ## Usage ### Define Models #### `User` model ```js class User extends Model { static schema () { return graphql` type User { id: ID! email: String! age: Int role: Role! } type UserQuery { user (email: String): User allUsers (): [User] } ` } static resolver () { return { user ({ email }) { // find user by email } } } } ``` #### `Role` model ```js class Role extends Model { static schema () { return graphql` type Role { name: String! users: [User] } type Query { userRoles (id: ID!): [Role] } ` } static resolver () { userRoles ({ userId }) { // select roles from role where role.user_id = userId } } } ``` ## References - Spec and Schema - https://facebook.github.io/graphql/ - https://github.com/graphql/graphql-js - https://www.reindex.io/blog/building-a-graphql-server-with-node-js-and-sql/ - Querying - http://graphql.org/docs/queries/ - https://facebook.github.io/relay/docs/graphql-connections.html#content - https://github.com/graphql/graphql-relay-js - Mutations - https://facebook.github.io/relay/docs/graphql-mutations.html#content - https://medium.com/@HurricaneJames/graphql-mutations-fb3ad5ae73c4#.cntgoeljn [npm-image]: https://img.shields.io/npm/v/trailpack-graphql.svg?style=flat-square [npm-url]: https://npmjs.org/package/trailpack-graphql [ci-image]: https://img.shields.io/travis/langateam/trailpack-graphql/master.svg?style=flat-square [ci-url]: https://travis-ci.org//trailpack-graphql [daviddm-image]: http://img.shields.io/david/langateam/trailpack-graphql.svg?style=flat-square [daviddm-url]: https://david-dm.org/langateam/trailpack-graphql [codeclimate-image]: https://img.shields.io/codeclimate/github/langateam/trailpack-graphql.svg?style=flat-square [codeclimate-url]: https://codeclimate.com/github/langateam/trailpack-graphql