Skip to content

Sparse Update POC: Graphql-java interception

Pre-release
Pre-release

Choose a tag to compare

@krutikavk krutikavk released this 13 Aug 23:33
· 2 commits to validate-presence-fields since this release

Description

Sparse Update POC with : Graphql-java interception
This implementation overrides instrumentation for graphql-java to add raw variables from mutation input to graphql context.

Please use git checkout graphql-java-interception to try this out.

Mutation:

query getShow {
  show(id:"one") {
    title
    releaseYear
  }
}

//output
{
  "data": {
    "show": {
      "title": "Show One",
      "releaseYear": 2023
    }
  }
}
mutation updateShow($input: UpdateShowInput!) {
  updateShow(input: $input) {
    id
    title
    releaseYear
  }
}

// Variables
{
  "input": {
    "id": "one",
    "title": "New Show"
  }
}

// output
{
  "data": {
    "updateShow": {
      "id": "one",
      "title": "New Show",
      "releaseYear": 2023
    }
  }
}

Title is updated to "New Show" without affecting the value of "releaseYear" even though it is not supplied by the client in input variables.

Implementation used:

  1. Adding raw variables to dfe context through customized graphql-java instrumentation for beginExecution
  2. Presence (boolean) fields for title and releaseYear