Skip to content

Server side application to track gardening activities. Built with CosmosDB, gRPC and GraphQL.

Notifications You must be signed in to change notification settings

vgkholla/plant-tracker

Repository files navigation

plant-tracker

Build Status Codacy Badge

Playing with CosmosDB and GraphQL

To try, first create a CosmosDB account that has a Database with name "PlantsTracker" and container with name "plants"

Then run

./gradlew run --args="--cosmosDBAccountEndpoint COSMOS_DB_ACCOUNT_ENDPOINT --cosmosDBAccountKey COSMOS_DB_ACCOUNT_KEY --cosmosDBPreferredRegions COSMOS_DB_ACCOUNT_PREFERRED_REGION1,COSMOS_DB_ACCOUNT_PREFERRED_REGION2"

Navigate to http://localhost:8080/ and try out the following queries

Create plant
mutation {
  createPlant(input: { plant: {
    id: "ptracker:plant:myplant",
    name: "MyPlant"
  }}) {
    name
  }
}
Get created plant
{
  getPlant(input: { id: "ptracker:plant:myplant"}) {
    name
  }
}
Update plant
mutation {
  updatePlant(input: { plant: {
    id: "ptracker:plant:myplant",
    name: "MyPlantUpdated"
  }, shouldUpsert: true}) {
    name
  }
}
Get updated plant
{
  getPlant(input: { id: "ptracker:plant:myplant"}) {
    name
  }
}
Delete plant
mutation {
  deletePlant(input: { id: "ptracker:plant:myplant"}) {
    _
  }
}
Try to get deleted plant
{
  getPlant(input: { id: "ptracker:plant:myplant"}) {
    name
  }
}