0.4.3 • Published 7 years ago

graphql-sequelize-crud-teselagen v0.4.3

Weekly downloads
11
License
MIT
Repository
github
Last release
7 years ago

graphql-sequelize-crud

CircleCI

codecov

Automatically generate queries and mutations from Sequelize models


Demo
See demo/index.js for demo source code.
The following is automatically generated from a simple Sequelize schema. graph Generated using graphql-viz.

Installation

# Install Peer Dependencies
npm install --save graphql graphql-relay graphql-sequelize-teselagen sequelize
# Install GraphQL-Sequelize-CRUD
npm install --save graphql-sequelize-crud-teselagen

Updating NPM Package:

npm run release

Usage

See demo/index.js for demo source code.

// Project Dependencies.
const Sequelize = require('sequelize');
const { getSchema } = require('graphql-sequelize-crud');

// Optional: Use express-graphql.
const express = require('express');
const graphqlHTTP = require('express-graphql');
const app = express();

// Create Sequelize instance.
const sequelize = new Sequelize(/* configure Sequelize */);

// Define Sequelize models.
// See demo source code.
// ...

// Generate GraphQL Schema from Sequelize instance and models.
const schema = getSchema(sequelize, options);
//available options and their defaults are:
//{
//  postgresOnly: false //(set to true if you only need to support postgres, makes bulk creates faster!)
//} 

// Optional: Create express-graphql server.
app.use('/graphql', graphqlHTTP({
  schema: schema,
  graphiql: true
}));
const port = 3000;
app.listen(port, () => {
  console.log(`Listening on port ${port}`);
});

Why

  • :white_check_mark: Less error prone development. No more keeping GraphQL in sync with Database fields.
  • :white_check_mark: Don't Repeat Yourself.
  • :white_check_mark: Power of GraphQL and Relay with rapid database development of Sequelize

Features

  • Generated GraphQL API only from Sequelize Models defintitions
    • Relay compatiable GraphQL API
  • Generate Queries
    • READ single
    • READ all
  • Generate Mutations
    • CREATE
    • UPDATE
    • DELETE
  • Custom queries and mutations within Sequelize Models defitions
0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago