When a Medplum GraphQL API query beats several FHIR REST calls
A team building a clinical view or a constrained client often needs one patient plus their conditions, medications, encounters and practitioners on a single screen. Medplum's FHIR R4 API includes GraphQL support, which can fetch those linked resources in one request instead of a chain of REST searches. Per Medplum's documentation, the GraphQL endpoint sits alongside the REST API in the same server, so the data is read through the same authentication and access policies as any other call. The server itself is part of the medplum/medplum repository, which is Apache 2.0 licensed and is where you can confirm the GraphQL behavior for the release you plan to run.
GraphQL is worth evaluating when the client needs a fixed, nested shape of data and the number of round trips matters: a mobile app on a poor connection, a kiosk, or a third-party widget that should receive only the fields its screen uses. Choosing the query shape is the main design decision, because a broad query pulls more data than the screen needs and is harder to audit. Before committing, confirm how your team will measure response size and latency on your own dataset, and whether your FHIR quota model counts a GraphQL request the same way as a REST search.
GraphQL is not the right tool for everything. Bulk exports, large population queries, write-heavy workflows and searches that depend on FHIR search parameters, paging or _include semantics are usually better served by the REST API or the bulk export path. Use GraphQL where the read pattern is known and bounded, and keep REST for the rest. Plan that split early, because mixing the two in one client increases the number of permission rules you must test.
Which GraphQL setting fits which client
This table compares the GraphQL configuration choices for Medplum's FHIR GraphQL API, from read-only queries to mutations, field selection breadth, introspection and identity type. Read each row as a setting, when it fits and the main trade-off to accept before you enable it in production.
| Setting | Fits when | Main trade-off |
|---|---|---|
| Read-only queries | Dashboards, reporting views and clinical lookups that only need to read linked patient, encounter or observation data | Writes must go through a separate REST or transaction path, so a second access review is needed for that client |
| Mutations | Trusted backends or workflows that create or update resources and must do so in the same policy boundary as the reads | Each mutation widens the blast radius of a leaked credential, so scope it tightly in access policies and log it |
| Broad field selection | Trusted server-side services such as Bots or integration jobs that need many linked resources in one request | Large selection sets produce heavier queries and bigger responses, which affects server load and the data a compromised client could read |
| Narrow field selection | Browser or mobile clients that should receive only the fields a screen needs, which limits exposure of PHI | Developers must maintain the field list as screens change, and missing fields show up as runtime errors rather than compile-time warnings |
| Introspection enabled | Local development and staging, where engineers need the schema to build and test queries | The full schema becomes readable to anyone who can reach the endpoint, which helps an attacker map the data model |
| Introspection disabled | Production endpoints exposed to end users, partners or networks outside your controlled perimeter | Tooling that depends on live schema lookup needs a checked-in schema file instead, and that file must be kept in sync |
| User-level access | Clinicians, patients or staff acting for themselves, where every read should be attributable to a person | Sign-in and MFA requirements apply to each request path, and session lifetimes must suit the clinical workflow |
| Client-credential access | Server-to-server jobs with no human in the loop, such as nightly reconciliation or a scheduled sync | The credential becomes a standing high-value secret, so rotation, storage and access policy scope must be set deliberately |
Setting up GraphQL access on a Medplum project
This sequence takes a Medplum deployment from version confirmation to a promoted GraphQL setup in which a dedicated client can reach only the resources its policies allow. Each step ends with a check so the team knows the layer is working before the next one builds on it.
Confirm the deployment and version
Record whether the project runs on Medplum Cloud or a self-hosted server, and which server version is installed. Compare that version with the current release in the medplum/medplum GitHub releases page and with the versioning policy, so the team knows which GraphQL behavior and security patch window apply. For self-hosted systems, confirm the version against the upgrading guide before changing anything. Done when the version, hosting model and owner are written in the change record.
Create a dedicated client application
Create a separate client application in the target project for the GraphQL consumer, rather than reusing an administrator login or a shared application. Choose the authentication method that matches the caller: a client credentials flow for a server-to-server service, or an user-facing sign-in flow for an application acting for a user. Record the client identifier and the owner who approves changes to it. Done when the client exists alone in the project, carries its own name, and a test token can be issued for it.
Define access policies before exposing queries
Write access policies for the client so it can read only the resource types and compartments the use case needs, and keep write access off unless a mutation is required. Attach the policy to the client application and review it with the data owner. GraphQL does not replace these rules, so every query path still runs through the same policy evaluation as the REST API. Done when the policy file is in version control and the owner has signed off on the resource list.
Test queries and mutations in a non-production project
Run the planned queries and mutations against a non-production project loaded with synthetic data. Confirm that a linked query returns the expected related resources in one request, and that each mutation writes only to the resource types the policy allows. Keep the test data free of real patient information. Done when every planned query returns the expected shape and each mutation behaves as the policy specifies.
Check that a restricted client cannot read out-of-scope resources
Using the dedicated client's token, request resource types, search parameters and linked fields that sit outside its policy. Include a relationship that would pull in a resource the client should not see, such as a record in another compartment. The expected result is an access denial or an empty result, and the same query must not leak data through a nested field. Done when every out-of-scope probe fails and the results are saved with the test record.
Review introspection and error exposure
Decide whether introspection is available to this client, and make sure error messages do not reveal server internals, stack traces, resource identifiers outside scope or configuration details. Confirm these settings in the current Medplum documentation for your version, because the exact controls can change between releases. Ask the platform owner to confirm what is visible to unauthenticated and to authenticated callers. Done when a reviewer has checked a sample of error responses and the introspection decision is recorded with its reason.
Promote the configuration to production
Apply the reviewed client, policy and settings to the production project through the same change process used for other configuration, not by hand in the console. Repeat the restricted-client probes against production using a credential with no real patient exposure, or with monitoring in place. Record who approved the change and set a review date for the policy. Done when the production checks match the non-production results and the change record links the test evidence.
Securing GraphQL queries against over-broad data access
A GraphQL request can reach across linked FHIR resources in a single call, so a query that looks narrow can return far more patient data than the caller should see. The cards below cover the controls that keep those requests inside the access a client is meant to have, and the operational settings that a self-hosted team owns.
Access policy as the main control
Access policies decide what each GraphQL query can return, not the shape of the query. Medplum applies the access policy attached to the calling project, membership or client to every resource the traversal touches. Check each linked resource type a client can reach, not only the root type it asks for, and test with a constrained client account that holds the access you intend to grant. Confirm that a query for a restricted resource returns nothing rather than a partial result.
Medplum auth docsDeep traversal of linked resources
Nested selections follow references from patients to encounters, observations, coverage and practitioners in one request. Each hop is a potential exposure path, so a client allowed to read patients may pick up related records it was never meant to see. Set a depth limit in your review, list the reference chains your clients rely on, and confirm that each nested type is covered by the same access rules as a direct search.
Introspection and error messages
Schema introspection tells a caller which types, fields and relationships exist, and error messages can echo field names or validation detail. Decide whether introspection stays on for each environment, and review error text returned to clients that should not see the internal model. Confirm the setting in your own deployment configuration, because the exact option names depend on your Medplum version.
Query cost and rate limiting
A deeply nested query can fan out into many database reads, which makes cost a security concern as well as a performance one. Define a maximum depth and a rate limit for each client class, and load-test the most expensive selections your applications send. Rate limit behavior is shaped by your gateway and server settings, so confirm the available limits with Medplum and in your own infrastructure before you rely on them.
Authentication method choice
Browser users, native apps and server-to-server jobs should not share one sign-in path. Interactive users sign in through Medplum Auth or an external identity provider with multi-factor authentication, while backend services use client credentials with narrowly scoped access policies. Map each caller to one method, document the token lifetime, and remove any shared credential that can run broad queries.
Logging who queried what
Access decisions are only reviewable if you can tie a query to a user or client, a time and a resource. Medplum records resource history and audit events, but the exact GraphQL request detail that is retained depends on your configuration and log pipeline. Confirm with Medplum which events are captured, where they are stored, and how long your own retention policy keeps them.
Self-hosted responsibility split
Medplum's compliance documentation states that compliance is a shared responsibility between Medplum and its customers. On a self-hosted deployment, your team owns the gateway, network exposure, logging pipeline, secrets, backups and the configuration of every setting above. Assign an owner to each control in writing, and confirm with your compliance team which evidence an auditor will expect you to produce.
Medplum compliance docsQuestions teams ask before building on the GraphQL API
Does GraphQL replace FHIR search on Medplum?
No. GraphQL is an additional way to query the same FHIR R4 data, and it does not replace FHIR search. Medplum's FHIR R4 API includes GraphQL support, so a single request can return a resource along with the linked resources it references. Teams usually keep FHIR search for paging, bulk lookups and standard parameters, and use GraphQL where a screen or client needs a resource and several related resources in one round trip. Whichever you choose, access policies apply to the data returned, so both paths need to be tested against the same rules.
What skills and effort does a GraphQL build need?
Your engineers need working knowledge of FHIR resource structure and references, GraphQL query design, and the Medplum SDK or HTTP clients that send the requests. Effort depends on how many screens or clients read data, how deeply the queries nest, and how much testing your access model requires. Plan time for mapping each consumer's needs to specific fields, writing query tests for the nested cases, and reviewing what each client can see. Ask your team to confirm the exact query shape and client libraries against the current Medplum documentation before estimating.
What drives the cost of a GraphQL implementation up or down?
Cost is driven by the number of queries, the depth of nesting across linked resources, the number of client types with different field permissions, and the volume of access policy testing. Hosted plan costs are separate from the implementation work. For current Medplum Cloud prices, see the Medplum pricing page, which lists Free, Production, Premium and custom Enterprise plans. Self-hosting is offered as a free Community option or as custom-priced Enterprise Self-Hosted. Infrastructure, operations and engineering time are additional costs under either model. Ask any partner for a quote built from a written scope listing consumers, queries and environments.
Can our in-house team build and run this without a partner?
Often yes, if your team already runs FHIR-based services and understands Medplum's access model. Teams without that background usually find the hardest parts are access policy design and field-level restriction for constrained clients, not the query syntax itself. A partner is most useful when you need an outside review of access rules before go-live, a defined test set, or help with a deployment that must meet your own security review. Decide by comparing your team's current FHIR and access control experience against the list of queries and clients you need to support.
What does the GraphQL work need from our infrastructure and identity setup?
GraphQL requests go through the same Medplum server as other API calls, so the work depends on how that server is hosted and how clients authenticate. Medplum supports Medplum as the identity provider, external identity providers such as Google, Auth0 or AWS Cognito, domain-level corporate identity providers, client credentials for server-to-server access, and multi-factor authentication. Confirm which identity model applies to each client, because the token a client holds determines which fields it can read. Self-hosted deployments also need a plan for PostgreSQL and Redis, the database and cache Medplum uses, and for TLS and network access to the API.
How do Medplum upgrades affect our GraphQL queries?
Upgrades can change server behavior, so every GraphQL query should be part of your regression suite before a version change. Self-hosted Medplum must be upgraded through each minor version in sequence, because skipping versions causes startup failures, as documented in the upgrading guide. Medplum ships major versions annually, minor versions two to three times a year and patch versions weekly, and each major version has 1 year of Active support and 1 year of Maintenance. Enterprise customers can extend security patches to 36 months in total. Check the Medplum versions and release policy and test queries on a staging copy before each upgrade.
Is introspection safe to leave on in production?
Treat it as a security decision rather than a default to keep. Introspection exposes the schema to any client that can reach the endpoint, which makes it easier for an attacker to map what can be queried. Decide per environment whether introspection stays on, and confirm the exact setting for your Medplum version in the documentation before changing it. Pair that decision with access policies so that a client only receives the fields its role allows, and test that unauthorized fields are not returned through nested references.
How a GraphQL request passes through Medplum's access checks
The request starts in a client app that signs in through Medplum Auth or an external identity provider and presents a bearer token to the GraphQL endpoint. Inside the self-hosted server, the endpoint hands the query to access policy evaluation before any data is read from PostgreSQL, so a request is only answered with resources the caller's project and policies allow. Check that every path into the server crosses the same policy step, and confirm how your deployment's identity provider issues tokens before you rely on the boundary.
Sign-in and GraphQL request path through the self-hosted server's access checks.
Running GraphQL queries safely after go-live
This sequence keeps Medplum GraphQL access predictable after launch by watching query behavior, reviewing policy changes, retesting after upgrades and rotating credentials on a schedule the team owns. The output is an operating record that shows who can query what, and evidence that it still works.
Baseline query volume and error patterns
The platform or integration team records which GraphQL operations run in production, which client applications send them, and the normal error rate for each. They pull these figures from the server logs and any gateway or proxy in front of the Medplum API, and they group requests by client ID so every caller has its own baseline. The step is done when the team has a written baseline per client and an agreed place where the dashboards live. Without this baseline, later spikes or new error types cannot be judged.
Alert on unexpected query changes
The team configures alerts for changes in volume, error codes and response shape for each client, and confirms which alerts page an on-call engineer and which go to a review queue. They also test that an alert fires by sending a controlled failing request from a non-production client. Confirm with your own monitoring stack how Medplum's logs are exported and how long they are retained. The step is done when a test alert reaches the named responder.
Review access policy changes on a fixed cadence
A security or data governance owner reviews changes to Medplum access policies, project settings and the introspection setting, since each change can alter which fields and linked resources a GraphQL query can return. The reviewer compares the current policies against the approved version kept in source control and signs off on any difference. Medplum's version history can help identify who changed a resource and when, so confirm how your team uses it. The step is done when every change since the last review has an approval record.
Retest queries before each Medplum upgrade
Before a self-hosted upgrade, the engineering team runs the saved GraphQL test suite against a staging copy of the deployment on the target version. Medplum ships minor versions two to three times a year and patch versions weekly, and the upgrading guide says each minor version must be applied in sequence, so each intermediate step needs its own test run. The step is done when every saved query returns the expected fields, policy outcomes and errors on the target version.
Retest queries after each major release
After a major version such as the annual Q4 release is deployed, the team repeats the full GraphQL test suite, including negative tests where a constrained client must be refused access to a field or resource. They check the release notes for changes to the GraphQL schema or access behavior, and they compare results with the pre-upgrade baseline. Confirm the support window for your major version in Medplum's versioning policy. The step is done when results match the baseline or each difference has a recorded decision.
Apply security patches within the policy window
When Medplum publishes a security patch, the operations team checks its CVSS rating against Medplum's targets, which call for critical vulnerabilities (CVSS 9.0 or higher) to be patched within 7 days and high ones (CVSS 7.0 to 8.9) within 14 days. They apply the patch to staging, rerun the GraphQL suite, and then promote it to production. The step is done when the deployed version matches the patched release and the test run is archived with the change record.
Rotate client credentials on a set schedule
The identity owner rotates client credentials used by server-to-server GraphQL callers, including client secrets, and confirms that each caller picks up the new credential before the old one is revoked. Medplum supports client credentials for server-to-server access and multi-factor authentication for users, so the team should document which mechanism each client uses. Choose a rotation interval that matches your own policy and confirm with your security team. The step is done when every client has a current credential, revoked credentials return errors, and the rotation is logged.
Primary sources for the Medplum API and deployment
The Medplum repository, release notes and documentation set the rules for any Medplum FHIR GraphQL API work. Read the versions policy, self-hosting, authentication and compliance pages together, because the API surface, upgrade cadence and access model all shape how a GraphQL endpoint is exposed and governed.
Medplum source repository
The medplum/medplum repository on GitHub contains the server, the FHIR R4 API with GraphQL support, the SDK and the Bots runtime. Check the GraphQL schema and server code in the version you run, because field availability and behavior can change between releases. Confirm your deployed version matches the code you review before drawing conclusions about query behavior or access enforcement.
- License
- Apache 2.0
Release notes and patch history
The releases page records each Medplum version with its publication date. Patch releases arrive weekly, so a GraphQL behavior you tested last month may have changed. Read the notes for any change touching search, GraphQL or access policies before you schedule an upgrade, and keep a record of the exact version under test.
- Latest release at research
- 5.2.5
Versions and support policy
The versions policy sets support windows for each major release and the security patch targets for critical and high vulnerabilities. Use it to decide which major version your GraphQL endpoint should run and how long an upgrade can wait. Ask your vendor or team to confirm which support tier applies to your self-hosted deployment.
- Critical patch target
- 7 days
Upgrade sequence for self-hosted servers
The upgrading guide requires stepping through each minor version in order, since skipping versions causes startup failures and long data migrations. Plan the GraphQL endpoint changes alongside each step and test each intermediate version in a staging copy. Ask how long the data migrations run on a dataset your size before setting a maintenance window.
Upgrading guideSelf-hosting options and infrastructure
The self-hosting documentation lists AWS with CDK and CloudFormation as the recommended path, along with Docker, Kubernetes, Ubuntu and Terraform-based options with Beta status for some clouds. Your deployment choice affects where the GraphQL endpoint sits behind your gateway, how TLS and rate limits are set, and who patches the stack. Confirm which option your security team has approved.
- Database
- PostgreSQL
Authentication and client access
The authentication documentation covers Medplum Auth, external identity providers, domain-level corporate identity, client credentials and multi-factor authentication. Each GraphQL caller needs a defined identity, whether a user, a client application or a server integration. Review which methods your constrained clients use and confirm the token lifetimes that apply to them.
Authentication docsCompliance responsibilities
The compliance documentation maps Medplum to HIPAA, SOC 2 Type II, HITRUST e1, CFR Part 11 and other frameworks, and states that compliance is shared between Medplum and the customer. For a self-hosted GraphQL endpoint, your team owns introspection settings, logging, access policy configuration and network exposure. Ask your assessor which of those controls they will test.
Compliance docsHow DeployOpen scopes and delivers a Medplum GraphQL build
DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure, and we apply the same method to Medplum FHIR GraphQL API. The work starts with a written scope that names the queries, mutations, access policies and client types in play, so the build can be reviewed before any code is written.
How we scope
- We inventory the screens, clients and data consumers that will call the GraphQL endpoint and record which resources each one needs.
- We map each query to its linked resources and flag any that would expose data beyond the intended access policy.
- The written scope defines the query set, field selections, introspection setting, access policy tests and handover items before work begins.
How we build
- We write and review GraphQL queries and mutations against your Medplum project, keeping field selections narrow for constrained clients.
- We configure access policies and client application settings so each client can reach only the resources and fields its scope allows.
- We test introspection settings in each environment and confirm that restricted clients receive denied or filtered results for out-of-scope data.
How we hand over
- You receive the query and mutation library, with each operation documented by purpose, caller and the resources it touches.
- You receive the access policy configuration, client definitions and test cases, so your security team can repeat the checks.
- We walk your engineers through the handover and record which items remain your responsibility to operate and review.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, which covers changes to queries as your clients evolve.
- When Medplum releases a new version, we can review GraphQL behavior and access policy effects before your planned upgrade window.
- Confirm with DeployOpen the response times, retest cycles and support hours that apply to your retainer before signing.

