Sequelize GraphQL Schema Builder and Node exporter example
The goal is to convert a MySQL Workbench Model to a complete GraphQL API for CRUD operations.
This example uses a slightly modified version of the Skila sample model from MySQL : removed unwanted schemas, renamed redundant foreign keys indexes names and modified lastUpdate
fields default values that sqlite does not implements.
The sample data script has been modified for sqlite.
The project loads arbitrary sequelize models, sync it to a Sqlite database stored in memory, and convert it to a complete GraphQL API.
Here, the Sequelize models are generated from a sample MySQL Workbench schema but you can use your own schema file or directly paste your models to src/models
(you have to remove its content before).
$ composer install
$ yarn
The project is written for node / ECMAScript module and targetted to use at least node 18. If you use nvm, issue :
$ nvm use
$ bin/mysql-workbench-schema-export --export=node-Sequelize6 --config=config/mysql-worbench-exporter.json data/sakila-db/sakila-modified.mwb
As written above, your models can be generated by other tools like sequelize-automate, or you can use your own MySQL Workbench schema too (You should then comment the sample data insertion in server.js
).
$ yarn test
Have a look at configuration files in the root directory and its config
subdirectory.
$ yarn start-dev
Note that sample data will be injected at startup.
The playground should be available at http://localhost:3331/api.
Sequelize GraphQL Schema Builder
To keep the example simple, branches exists to keep somme demonstartions independant. The master branch combine theme all together.