activeql
v1.0.2
Published
Domain Driven GrapqhQL API Development for NodeJS
Downloads
3
Maintainers
Readme
ActiveQL
A framework for building domain driven GraphQL APIs with an oppionated approach and convention over configuration and DRY in mind. Based on a simple domain configuration (mainly entities with attributes and their relationships) it
- generates a full GraphQL schema with aspects like searching, sorting, paging, permission access etc.
- provides a full fledged GraphQL API with resolvers - powered by Apollo and MongoDB (other Databases can be supported as well)
- provides an Admin UI for basic CRUD applications
- allows to be extended for any non-convention requirement with custom code
You can find the documentation here
Use ActiveQL
To develop applications with ActiveQL you do not need this package - you can start with one of the following
Application Generator
The easiest way to start is the ActiveQL application generator at https://github.com/betterobjects/activeql-generator
You can create a new ActiveQL application in the folder my-activeql
(or any other name) with the following command:
npx betterobjects/activeql-generator my-activeql
Starter-Application
If you can't use npx
you can also fork and clone the ActiveQL-Starter-Application at https://github.com/betterobjects/activeql-starter
git clone https://github.com/betterobjects/activeql-starter
Install dependencies
Please call npm install
in the folders
./express
./angular
You can safely delete the angular folder and skip all Angular related steps if you do not want to use the Admin UI but just the GraphQL API.
Start developing
In the folder ./express/activeql/domain-configuration
create a YAML file, e.g. car.yml
with the following content:
entity:
Car:
attributes:
licence: Key
brand: String!
mileage: Int
Start the server
cd express
npm run server
This will start a GraphqlAPI endpoint at http://localhost:3000/graphql
If you point your browser to this address you will find full fledged GraphQL API whith many queries and mutations you can interact with. For reading / storing data an embedded MongoDB-like database NeDB is used per default. You can change the used database of course.
To create a car you could call the mutation:
mutation {
createCar( car: { licence: "HH AQ 2021" brand: "Mercedes", mileage: 10000 } ){
car{ id licence brand mileage }
}
}
with the answer from your GraphQL API
{
"data": {
"createCar": {
"car": {
"id": "GjgoJZ9RNHPQ1Pij",
"licence": "HH AQ 2021",
"brand": "Mercedes",
"mileage": 10000
}
}
}
}
To run the Angular Admin UI together with the server you can run
cd express
npm run start
You can of course run the Angular application seperately with
cd ./angular
ng serve
The Admin UI will be served at http://localhost:4200
Custom configuration of the UI is done in the file
./angular/src/app/config/admin.config.ts
Please check out the Documentation for more.