Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

A sample and experimental polyglot Java and JavaScript app to show interaction between Quarkus (a k8s native Java Framework) and Graphback (providing OOTB GraphQL NodeJS API for your client and server)

Notifications You must be signed in to change notification settings

machi1990/quarkus-graphback-mongo

Repository files navigation

quarkus-graphback-mongo

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.

Running

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.

App Started

Playground

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.

Create A Fruit

mutation {
  createFruit(input: {name: "apple", description: "Apple description"}) {
    _id, 
    name,
    description
  }
}

Update A Fruit

mutation {
  updateFruit(input: {_id: "5f48c5027b5bfb2bfcc7e53b" description: "apple long description"}) {
    _id, 
    name,
    description
  }
}

List Fruits

List All

query {
  findFruits {
    items {
      _id,
      name,
      description
    }
    count
  }
}

Find Fruit by ID

query { 
  getFruit(id: "5f48c5027b5bfb2bfcc7e53b") {
    _id
    name
    description
  }
}

Delete Fruit

mutation {
  deleteFruit(input: {_id: "5f48c5027b5bfb2bfcc7e53b"}) {
    _id, 
    name,
    description
  }
}

Conlusion

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.

About

A sample and experimental polyglot Java and JavaScript app to show interaction between Quarkus (a k8s native Java Framework) and Graphback (providing OOTB GraphQL NodeJS API for your client and server)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published