A sample and experimental polyglot Java and JavaScript app to show interaction between Quarkus and Graphback.
This app is highly based on the example given in Using the Quarkus Mongo Client Extension.
The idea is to leverage the Mongo client provided by the extension and use some of Graphback capabilities to expose a GraphQL Crud API.
NOTE: The app does not follow a normal Quarkus application and thus a normal Quarkus application Lifecycle is not respected meaning resources like Mongo Connection may leak as they are not properly closed.
Make sure you have tools and software installed.
build the datasource
./mvnw clean install
Start the MongoDB server on another terminal tab using the provided docker-compose.yml
file.
bash docker-compose up
After that the app can be ran with
cd app
npm start
NB: Make sure that $GRAALVM_HOME
is set on your PATH.
This will start in http://localhost:4000
.
Open your browser to http://localhost:4000/graphql
.
Use the below queries to play a little with the application.
NOTE: We use the id
5f48c5027b5bfb2bfcc7e53b
for sake of completeness, replace this value with the one generated for you.
mutation {
createFruit(input: {name: "apple", description: "Apple description"}) {
_id,
name,
description
}
}
mutation {
updateFruit(input: {_id: "5f48c5027b5bfb2bfcc7e53b" description: "apple long description"}) {
_id,
name,
description
}
}
query {
findFruits {
items {
_id,
name,
description
}
count
}
}
query {
getFruit(id: "5f48c5027b5bfb2bfcc7e53b") {
_id
name
description
}
}
mutation {
deleteFruit(input: {_id: "5f48c5027b5bfb2bfcc7e53b"}) {
_id,
name,
description
}
}
This was an exercise I decided to kickstart my Learning Day that my company accorded to all employee. Combining my experiences in both of these frameworks was fun.
- It should be possible to make the data provider generic enough so that it work with any kind of business model and more than one business model.
- Extend the data provider with filtering capabilities
- Quarkus resources lifecycle management
- One possible paths that this may lead is to use the Debezium Extension and use it to setup Graphback Subscriptions.