GraphQL API
Aidbox supports default GraphQL implementation without any extensions (specification) Queries are supported, but mutations are not.
In Aidbox UI there is GraphiQL interface, you can try your queries there.
GraphQL console sends all your requests to $graphql
endpoint which you can use from your application too
GraphQL endpoint
POST
/$graphql
This endpoint allows you to execute GraphQL queries .
Request Body
query
string
GraphQL query
variables
object
JSON object with variables
Aidbox generates different GraphQL scalars, objects, queries with arguments and unions from FHIR metadata.
Queries
For each ResourceType these queries are generated:
<resourceType>
— get fields of the specified resource. Accepts a single argumentid
and returns a resource with the specifiedid
. Example:Patient (id: "pat-1")
\<resourceType>List
— search resources of given resource type. Accepts FHIR search parameters for that resourceType. SearchParameters have underscores instead of dashes and referenced later in this documentation assearch_parameter
. For each SearchParameter two arguments are generated:<search_parameter>
e.g.:PatientList(address_state: "CA")
Accepts a string. Is an equivalent of using FHIR search parameter<search_parameter>_list
e.g.:PatientList(language_list: ["en", "de"])
Accepts a list of strings. It is an equivalent of repeating search parameters in FHIR search.<search_parameter>_list
arg is needed because args can't be repeated in the GraphQL query.
<resourceType>History
— get resource history. Acceptsid
argument and returns history of the resource with the specifiedid
. Example:PatientHistory(id: "pt1", _sort: "txid") {name}
Examples
PatientList(language_list: ["en", "de"])
will return a set of Patients the same asGET /Patient?language=en&language=de
and those will be patients withen
ANDde
as their communication language specified\PatientList(language: "en,de")
will return a set of Patients the same asGET /Patient?language=en,de
and those will be patients withen
ORde
as their communication language specified\PatientList(language_list: ["en", "de,fr"])
will return a set of Patients the same asGET /Patient?language=en&language=de,fr
and those will be patients withen
AND (de
ORfr
) as their communication language specified\PatientList(language: "en", language: "de")
is an error, it will ignore alllanguage
arg repetitions except of the last and will return a set of Patients the same asGET /Patient?language=de
Objects
For each ResourceType object with fields is generated. For every FHIR resource attribute field is created. Also for attributes with Reference type unions are created for direct and reverse includes.
Handling _revinclude
FHIR GraphQL does not support _revinclude Search parameter. In Aidbox you can use reverse include in such format:
For example:
observations_as_subject
for Patient will be equivalent of _revinclude=Observation:subject
Here's an example showing how to create first class extension, search parameter and use it in GraphQL:
Example
This example demonstrates how to use fragments, both types of search parameter arguments and reverse includes.
Configure GraphQL
By default, Aidbox does in memory index cache warmup when the first request comes in.
You can change it to warmup cache on startup.
Last updated