cruddl0.8.1 • Public • Published
cruddl - create a cuddly GraphQL API for your database, using the GraphQL SDL to model your schema.
This TypeScript library creates an executable GraphQL schema from a model definition and provides queries and mutations to access a database. Currently, it supports the multi-model database ArangoDB. The concept being inspired by existing projects like prisma and join-monster, cruddl exploits the expressiveness of the Arango Query Language (AQL) to generate one tailored query for each GraphQL request.
- Schema definition using GraphQL types, fields and directives
- Modelling features like relations, embedded lists and objects
- Query features include filtering, sorting, cursor-based pagination and arbitrary nesting
- Schema validation
- Role-based authorization (field and type-based; static and data-dependent)
- Pluggable database backends (currently supports ArangoDB and an in-memory implementation)
npm install --save cruddl
Install ArangoDB and create a new database.
If you just want to explore the features, you can also use an in-memory database implementation - but don't use this for anything else.
Define your data model and create a project:
Then, create the GraphQL schema and serve it:
;;db.updateSchemaproject.getModel; // create missing collections;server.startconsole.log'Server is running on ';
Usage in a browser environment
The core of cruddl perfectly works in a browser (e.g., using webpack), and this can be useful to generate a mock GraphQL schema on the fly or to validate a cruddl project. However, the ArangoDB adapter only works with node imports like
path. Unless you configure webpack to provide mock modules for them, you will get an error when you import
cruddl in a webpack environment. To solve this, you can import the core symbols from
cruddl/core and the
Although the feature set is already quite extensive, this project is still in active development. A number of regression tests helps to avoid unexpected changes in behavior, but they do not yet cover all cases. Documentation is relatively sparse and will be extended in the future. We aim to contribute to the ongoing developments regarding GraphQL database interfaces and might change our API to more closely match these of other implementations in the future.