> For the complete documentation index, see [llms.txt](https://vincent-desmares.gitbook.io/graphql-sequelize-generator/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vincent-desmares.gitbook.io/graphql-sequelize-generator/master.md).

# Graphql-Sequelize-Generator

## What can I do with GSG?

The tools provided by this library will allow you to:

* Query any models and associated ones through Graphql.
* Auto-generate create/update/delete mutations.
* Define before/after hooks and all resolvers, including the mutations.
* Easily create custom mutations.
* Get an integrated interface to test your Graphql API.
* Counts for each model can also be generated.
* Subscriptions auto-generated for mutations.
* Add custom fields/resolvers/subscriptions on auto-generated types.
* Easily add fully custom endpoints

## Getting started

Add the lib and the peer dependencies:

```
$ yarn add graphql-sequelize-generator graphql sequelize graphql-sequelize
```

{% hint style="warning" %}
Caution: GSG requires at least Node v9.11.2 or greater as it is using async/await.
{% endhint %}

Then you will be ready to add a GraphQL API to your express server.

```javascript
const express = require('express')
const {
  generateModelTypes,
  generateGraphqlExpressMiddleware
} = require('graphql-sequelize-generator')
const models = require('./models')

const types = generateModelTypes(models)

graphqlSchemaDeclaration.user = {
  model: models.user,
  actions: ['list', 'create']
}

const server = generateApolloServer({
  graphqlSchemaDeclaration,
  types,
  models
})

const app = express()
server.applyMiddleware({
  app,
  path: '/graphql'
})
```
