New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

trailpack-graphql

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trailpack-graphql

GraphQL Support for Trails

  • 0.9.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

trailpack-graphql

NPM version Build status Dependency Status Code Climate

This is a draft proposal

This trailpack provides a Relay-compatible GraphQL implementation for Trails.

Install

$ npm install --save trailpack-graphql

Configure

// config/main.js
module.exports = {
  packs: [
    // ... other trailpacks
    require('trailpack-graphql')
  ]
}

Usage

Define Models

User model
class User extends Model {
  static schema () {
    return graphql`

      type User {
        id: ID!
        email: String!
        age: Int
        role: Role!
      }

      type Query {
        user (email: String): User
        allUsers (): [User]
      }
    `
  }

  static resolver () {
    return {
      user ({ email }) {
        // find user by email
      }
    }
  }
}
Role model
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

Keywords

FAQs

Package last updated on 08 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc