Skip to content

Commit

Permalink
Implement Operation $graphql
Browse files Browse the repository at this point in the history
Currently only very view fields of Patient and Observation are
supported.
  • Loading branch information
alexanderkiel committed Feb 28, 2023
1 parent 37f9882 commit a45b622
Show file tree
Hide file tree
Showing 39 changed files with 829 additions and 61 deletions.
11 changes: 11 additions & 0 deletions .github/scripts/graphql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
. "$SCRIPT_DIR/util.sh"

BASE="http://localhost:8080/fhir"
TYPE=$1
EXPECTED_SIZE=$(curl -s "$BASE/${TYPE}?_summary=count" | jq -r .total)
ACTUAL_SIZE=$(curl -s -H "Content-Type: application/graphql" -d "{ ${TYPE}List { id } }" "$BASE/\$graphql" | jq ".data.${TYPE}List | length")

test "size" "$ACTUAL_SIZE" "$EXPECTED_SIZE"
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
- luid
- metrics
- openid-auth
- operation-graphql
- operation-measure-evaluate-measure
- page-store
- page-store-cassandra
Expand Down Expand Up @@ -531,6 +532,12 @@ jobs:
- name: Conditional Update If-None-Match
run: .github/scripts/conditional-update-if-none-match.sh

- name: GraphQL Patient
run: .github/scripts/graphql.sh Patient

- name: GraphQL Observation
run: .github/scripts/graphql.sh Observation

not-enforcing-referential-integrity-test:
needs: build
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -1238,6 +1245,12 @@ jobs:
- name: Conditional Update If-None-Match
run: .github/scripts/conditional-update-if-none-match.sh

- name: GraphQL Patient
run: .github/scripts/graphql.sh Patient

- name: GraphQL Observation
run: .github/scripts/graphql.sh Observation

- name: Docker Stats
run: docker stats --no-stream

Expand Down
8 changes: 7 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
blaze/interaction
{:local/root "modules/interaction"}

blaze.operation/graphql
{:local/root "modules/operation-graphql"}

blaze.operation/measure-evaluate-measure
{:local/root "modules/operation-measure-evaluate-measure"}

Expand Down Expand Up @@ -80,7 +83,7 @@
:outdated
{:replace-deps
{com.github.liquidz/antq
{:mvn/version "2.2.992"}
{:mvn/version "2.2.999"}

org.slf4j/slf4j-nop
{:mvn/version "2.0.6"}}
Expand Down Expand Up @@ -114,6 +117,7 @@
"-d" "modules/metrics"
"-d" "modules/module-base"
"-d" "modules/openid-auth"
"-d" "modules/operation-graphql"
"-d" "modules/operation-measure-evaluate-measure"
"-d" "modules/page-store"
"-d" "modules/page-store-cassandra"
Expand All @@ -127,6 +131,8 @@
"-d" "modules/test-util"
"-d" "modules/thread-pool-executor-collector"
"--exclude" "com.taoensso/timbre"
"--exclude" "org.antlr/antlr4"
"--exclude" "org.eclipse.jetty/jetty-server"
"--exclude" "org.clojure/alpha.spec"
"--exclude" "com.walmartlabs/lacinia"
"--exclude" "lambdaisland/kaocha"]}}}
4 changes: 4 additions & 0 deletions docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

A section about FHIR Search performance can be found [here](performance/fhir-search.md).

## GraphQL

A section about GraphQL performance can be found [here](performance/graphql.md).

## Transaction Bundle Upload - Summary

| CPU | # Cores | RAM (GB) | Xmx | MBJ³ | -c¹ | # Resources | Disk Util.² | Duration (s) | Resources/s |
Expand Down
32 changes: 32 additions & 0 deletions docs/performance/graphql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# GraphQL

## Simple Code Search

In this section, GraphQL for selecting Observation resources with a certain code is used.

### Download of Resources

All measurements are done after Blaze is in a steady state with all resources to download in it's resource cache in order to cancel out resource load times from disk or file system cache.

Download is done using the following `curl` command:

```sh
curl -s -H "Content-Type: application/graphql" -d "{ ObservationList { subject { reference } } }" "http://localhost:8080/\$graphql" > /dev/null"
```
| CPU | Heap Mem | Block Cache | # Res. ¹ | # Obs. ² | Code | # Hits | Time (s) | T / 1M ³ |
|------------|---------:|------------:|---------:|---------:|---------|-------:|---------:|---------:|
| EPYC 7543P | 8 GB | 1 GB | 29 M | 28 M | 17861-6 | 171 k | 1.045 | 6.11 |
| EPYC 7543P | 8 GB | 1 GB | 29 M | 28 M | 39156-5 | 967 k | 5.740 | 5.94 |
| EPYC 7543P | 8 GB | 1 GB | 29 M | 28 M | 29463-7 | 1.3 M | 8.057 | 6.20 |
| EPYC 7543P | 30 GB | 10 GB | 292 M | 278 M | 17861-6 | 1.7 M | 10.744 | 6.32 |
| EPYC 7543P | 30 GB | 10 GB | 292 M | 278 M | 39156-5 | 9.7 M | 70.122 | 7.23 |
| EPYC 7543P | 30 GB | 10 GB | 292 M | 278 M | 29463-7 | 13 M | 96.735 | 7.44 |
¹ Number of Resources, ² Number of Observations, ³ Time in seconds per 1 million resources, The amount of system memory was 128 GB in all cases.
According to the measurements, the time needed by Blaze to deliver Observations containing only the subject reference is about **twice as fast** as returning the same information via [Subsetted FHIR Search](fhir-search.md#download-of-resources-with-subsetting) and **4 times as fast** as downloading the whole Observation Resources using [FHIR Search](fhir-search.md#download-of-resources).
## Used Dataset
The dataset was the same as in [FHIR Search](fhir-search.md) performance tests.
11 changes: 0 additions & 11 deletions modules/interaction/.clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,16 @@
blaze.async.comp/do-sync clojure.core/let
blaze.db.api-stub/with-system-data clojure.core/with-open
blaze.interaction.create-test/with-handler clojure.core/fn
blaze.interaction.create-test/with-handler-data clojure.core/fn
blaze.interaction.delete-test/with-handler clojure.core/fn
blaze.interaction.delete-test/with-handler-data clojure.core/fn
blaze.interaction.history.instance-test/with-handler clojure.core/fn
blaze.interaction.history.instance-test/with-handler-data clojure.core/fn
blaze.interaction.history.system-test/with-handler clojure.core/fn
blaze.interaction.history.system-test/with-handler-data clojure.core/fn
blaze.interaction.history.type-test/with-handler clojure.core/fn
blaze.interaction.history.type-test/with-handler-data clojure.core/fn
blaze.interaction.read-test/with-handler clojure.core/fn
blaze.interaction.read-test/with-handler-data clojure.core/fn
blaze.interaction.search-compartment-test/with-handler clojure.core/fn
blaze.interaction.search-compartment-test/with-handler-data clojure.core/fn
blaze.interaction.search-system-test/with-handler clojure.core/fn
blaze.interaction.search-system-test/with-handler-data clojure.core/fn
blaze.interaction.search-type-test/with-handler clojure.core/fn
blaze.interaction.search-type-test/with-handler-data clojure.core/fn
blaze.interaction.transaction-test/with-handler clojure.core/fn
blaze.interaction.transaction-test/with-handler-data clojure.core/fn
blaze.interaction.update-test/with-handler clojure.core/fn
blaze.interaction.update-test/with-handler-data clojure.core/fn
blaze.test-util/with-system clojure.core/with-open}

:linters
Expand Down
4 changes: 2 additions & 2 deletions modules/interaction/test/blaze/interaction/create_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[blaze.fhir.response.create-spec]
[blaze.fhir.spec.type]
[blaze.interaction.create]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.interaction.util-spec]
[blaze.test-util :as tu :refer [given-thrown with-system]]
[clojure.spec.alpha :as s]
Expand Down Expand Up @@ -95,7 +95,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{handler# :blaze.interaction/create} system]
~txs
(let [~handler-binding (-> handler# wrap-defaults wrap-error)]
Expand Down
3 changes: 1 addition & 2 deletions modules/interaction/test/blaze/interaction/delete_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[blaze.db.api-stub :refer [mem-node-system with-system-data]]
[blaze.executors :as ex]
[blaze.interaction.delete]
[blaze.interaction.test-util :as itu]
[blaze.test-util :as tu :refer [given-thrown]]
[clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]
Expand Down Expand Up @@ -55,7 +54,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{handler# :blaze.interaction/delete} system]
~txs
(let [~handler-binding handler#]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[blaze.db.api-stub :refer [mem-node-system with-system-data]]
[blaze.interaction.history.instance]
[blaze.interaction.history.util-spec]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.test-util :as tu :refer [given-thrown]]
Expand Down Expand Up @@ -91,7 +91,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction.history/instance} system]
~txs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
[blaze.db.api-stub :refer [mem-node-system with-system-data]]
[blaze.interaction.history.system]
[blaze.interaction.history.util-spec]
[blaze.interaction.test-util :as itu]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.test-util :as tu :refer [given-thrown]]
Expand Down Expand Up @@ -93,7 +92,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction.history/system} system]
~txs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
[blaze.db.api-stub :refer [mem-node-system with-system-data]]
[blaze.interaction.history.type]
[blaze.interaction.history.util-spec]
[blaze.interaction.test-util :as itu]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.test-util :as tu :refer [given-thrown]]
Expand Down Expand Up @@ -94,7 +93,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction.history/type} system]
~txs
Expand Down
4 changes: 2 additions & 2 deletions modules/interaction/test/blaze/interaction/read_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[blaze.db.api-stub :refer [mem-node-system with-system-data]]
[blaze.db.spec]
[blaze.interaction.read]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.test-util :as tu]
Expand Down Expand Up @@ -43,7 +43,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction/read} system]
~txs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[blaze.interaction.search.nav-spec]
[blaze.interaction.search.params-spec]
[blaze.interaction.search.util-spec]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.page-store-spec]
Expand Down Expand Up @@ -99,7 +99,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction/search-compartment} system]
~txs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[blaze.interaction.search.nav-spec]
[blaze.interaction.search.params-spec]
[blaze.interaction.search.util-spec]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.page-store-spec]
Expand Down Expand Up @@ -101,7 +101,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction/search-system} system]
~txs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[blaze.interaction.search.nav-spec]
[blaze.interaction.search.params-spec]
[blaze.interaction.search.util-spec]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.middleware.fhir.db :refer [wrap-db]]
[blaze.middleware.fhir.db-spec]
[blaze.page-store-spec]
Expand Down Expand Up @@ -171,7 +171,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{node# :blaze.db/node
handler# :blaze.interaction/search-type} system]
~txs
Expand Down
6 changes: 0 additions & 6 deletions modules/interaction/test/blaze/interaction/test_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,3 @@
(fn [request]
(-> (handler request)
(ac/exceptionally handler-util/error-response))))


(defn extract-txs-body [more]
(if (vector? (first more))
[(first more) (next more)]
[[] more]))
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[blaze.interaction.delete]
[blaze.interaction.read]
[blaze.interaction.search-type]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.interaction.transaction]
[blaze.interaction.update]
[blaze.interaction.util-spec]
Expand Down Expand Up @@ -177,7 +177,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{handler# :blaze.interaction/transaction
router# ::router} system]
~txs
Expand Down
4 changes: 2 additions & 2 deletions modules/interaction/test/blaze/interaction/update_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[blaze.executors :as ex]
[blaze.fhir.response.create-spec]
[blaze.fhir.spec.type]
[blaze.interaction.test-util :as itu :refer [wrap-error]]
[blaze.interaction.test-util :refer [wrap-error]]
[blaze.interaction.update]
[blaze.test-util :as tu :refer [given-thrown with-system]]
[clojure.spec.alpha :as s]
Expand Down Expand Up @@ -98,7 +98,7 @@


(defmacro with-handler [[handler-binding] & more]
(let [[txs body] (itu/extract-txs-body more)]
(let [[txs body] (tu/extract-txs-body more)]
`(with-system-data [{handler# :blaze.interaction/update} system]
~txs
(let [~handler-binding (-> handler# wrap-defaults wrap-error)]
Expand Down
22 changes: 22 additions & 0 deletions modules/operation-graphql/.clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{:lint-as
{blaze.anomaly/when-ok clojure.core/let
blaze.fhir.operation.graphql-test/with-handler clojure.core/fn
blaze.test-util/with-system clojure.core/with-open}

:linters
{:unsorted-required-namespaces
{:level :error}

:single-key-in
{:level :warning}

:keyword-binding
{:level :error}

:reduce-without-init
{:level :warning}

:warn-on-reflection
{:level :warning :warn-only-on-interop true}}

:skip-comments true}
Loading

0 comments on commit a45b622

Please sign in to comment.