sequelize-relay
This is a library to allow the easy creation of Relay-compliant servers using sequelize, graphql-js and graphql-relay-js.
Dependencies:
- sequelize - an easy-to-use multi sql dialect ORM for Node.js & io.js. It currently supports MySQL, MariaDB, SQLite, PostgreSQL and MSSQL.
- graphql-relay-js - A library to help construct a graphql-js server supporting react-relay.
- graphql-js - A reference implementation of GraphQL for JavaScript.
Getting Started
This library is designed to work with the graphql-relay-js implementation of a GraphQL server using Sequelize.
- Setup a new npm project
- Run
npm install graphql graphql-relay-js sequelize sequelize-relay --save-dev
- Setup a Sequelize Server
- Setup your GraphQL Schema
- Use graphql-relay-js, sequelize, and sequelize-relay helper functions and win.
- Common Patterns, helper methods, etc in the References page.
Methods
getArrayData - Converts an
Array
of<SequelizeModel>
instances to anArray
ofobjects. getModelsByClass - Returns an
Array
of<SequelizeModel>
instances that are of the passed-inSequelizeClass
.resolveArrayByClass - First, it internally resolves an an
Array
of<SequelizeModel>
instances that are of the passed-inSequelizeClass
. Then it converts the array into a promisedArray
of<Attributes>
objects.resolveArrayData - Converts a promised
Array
of<SequelizeModel>
instances into a promisedArray
of<Attributes>
objects.resolveModelsByClass - Returns a promised
Array
of<SequelizeModel>
objects bySequelizeClass
.