Skip to main content

Reading and writing resources

API Fundamentals​

Service Endpoint​

https://backbone.medbackend.com/graphql

Authentication Requirements:

Authorization: Bearer <JWT_TOKEN>

Environment Setup​

# Verify connectivity
curl -H "Authorization: Bearer $TOKEN" $ENDPOINT \
-d '{"query":"{ Me { reference } }"}'

Core Request Patterns​

Identity Verification​

query IdentityCheck {
Me {
reference
}
}

Me has exactly one field, reference. It is built from the entity_type and entity_id claims in your token — "Patient/123", "Practitioner/abc", "Device/xyz" — and is null if either claim is missing. There is no resourceType field on Me; read the type off the reference instead.

Usage Scenario: Validate authentication context before sensitive operations


Resource Operations​

Create Resources​

mutation AddPatient($input: PatientCreateInput!) {
PatientCreate(resource: $input) {
id
meta { versionId lastUpdated }
}
}

Mutation fields are named <Resource><Verb>, not <Verb><Resource> — PatientCreate, PatientUpdate, PatientDelete, PatientValidate. The same holds for every resource: ObservationCreate, EncounterUpdate, and so on.

Dry run before you write: PatientValidate(resource: $input) takes the same PatientCreateInput and persists nothing, returning { valid errors { field message severity } }.


Read Operations​

Single Resource Retrieval​

query FetchPatient($id: ID!) {
Patient(id: $id) {
name { given family }
address { line city }
}
}

Search Methods​

Basic search (PatientList):

query BasicSearch {
PatientList(name: "Smith", birthdate: "ge2000-01-01") {
id
name { given family }
}
}

Paginated search (PatientConnection):

query PaginatedSearch {
PatientConnection(name: "John", count: 25) {
pagesize
next
edges {
resource {
id
name { given family }
}
}
}
}

count bounds how many rows you may see, not how many matched. A PatientConnection response has pagesize, next and edges — there is no totalCount or pageInfo field. If edges comes back shorter than count, that is not end-of-data: keep requesting the next page (pass next back as cursor) until next is null. PatientList has no cursor, and its offset argument is rejected with a 400 rather than honoured — this FHIR server pages by continuation token, not by offset. Use PatientConnection for anything that might span more than one page.


Update Operations​

mutation UpdateContact($id: ID!, $input: PatientUpdateInput!) {
PatientUpdate(id: $id, resource: $input) {
meta { lastUpdated }
telecom { system value }
}
}

The id is a separate argument, not a field of resource. Send the whole resource: the mutation writes exactly the fields you pass and does not merge them with what is stored, so anything you omit is dropped.


Delete Operations​

mutation RemovePatient($id: ID!) {
PatientDelete(id: $id) {
id
reference
}
}

PatientDelete takes id and nothing else, and returns a bare reference to what it deleted (id, plus reference as "Patient/<id>") — there is no issue field on the result. Deleting an id that does not exist is an error, not a no-op.


Search Implementation​

Complex Queries​

query AdvancedSearch {
PatientConnection(
name: "smith",
_tag: "research-study-45",
_lastUpdated: "ge2023-01-01"
) {
edges {
resource {
id
name { family given }
extension { url valueString }
}
}
}
}

Every FHIR search parameter HL7 defines for the resource is an argument, spelled the way HL7 spells it: birthdate, address_city, _tag, _lastUpdated, _sort. Six are not exposed. _filter, _text, _content and _query are omitted because the FHIR server behind this API ignores them and answers with the unfiltered result set; _count and _cursor are omitted because the count and cursor arguments already do that job.


Development Tools​

Interactive Playground​

https://backbone.medbackend.com/playground

The playground is off by default. /playground and its data endpoint /graphql-simple both return 404 unless the project configuration sets playground.enabled: true. /graphql is unaffected and is always the endpoint to integrate against.

Header Configuration:

{
"Authorization": "Bearer eyJhbGciOiJIUz...",
"X-Request-ID": "custom-correlation-id"
}

Playground Features:

  • Schema documentation sidebar
  • Query variable injection
  • Response formatting presets
  • Request history persistence

API Client Configuration​

Postman Setup Template​

Collection Variables:

{
"base_url": "{{environment}}/graphql",
"token": "{{jwt_secret}}"
}

Sample Request:

query GetRecentPatients {
PatientConnection(_sort: "-_lastUpdated", count: 5) {
edges {
resource {
id
name { given family }
}
}
}
}

Security Operations​

Production Hardening​

  • Playground — leave playground.enabled unset (or false) in the project configuration. That is the default, and it closes both /playground and /graphql-simple. /graphql itself still serves the GraphiQL IDE on a browser GET, and there is no setting that turns that or schema introspection off.
  • Rate limiting — the platform does not block or refuse any request for exceeding a rate today. A log-only counter runs against /graphql and /graphql-simple — it's one decorator on the shared view class, so both mount points share one bucket; crossing it is logged, not enforced, so no request is ever refused because of it. Put a limiter in front of your own integration; do not rely on one here.
  • Authentication — every GraphQL request that touches FHIR data is authenticated, including the playground's own endpoint. Schema introspection (__schema, __type, and similarly named fields) is the one exception: it is served without a credential, and there is no setting that closes it.

Operational FAQ​

Data Handling​

Q: How are extensions managed?
A: Every resource type carries an extension list, selected as extension { url valueString } and written like any other field. The query cannot filter extensions by url — select them and filter client-side.

Interface Support​

Q: REST API availability?
A: There is no REST parity for reading or writing resources — there is no /api/fhir/r4/ route, and GraphQL at /graphql is the surface for that. The one exception is /metadata, a plain GET/HEAD endpoint serving the FHIR CapabilityStatement; it carries no patient data and, per FHIR's own convention for this endpoint, is unauthenticated. The other HTTP routes are not FHIR: /health for diagnostics, /api/account/ for registration, device tokens and device status, and /v1/ for the OpenAI-compatible chat API.