Skip to content

eobeda/graphql-sequelize-crud

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-sequelize-crud

NPM NPM

Build Status

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 sequelize
# Install GraphQL-Sequelize-CRUD
npm install --save graphql-sequelize-crud

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);

// 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

  • ✅ Less error prone development. No more keeping GraphQL in sync with Database fields.
  • Don't Repeat Yourself.
  • ✅ 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

About

Automatically generate queries and mutations from Sequelize models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%