Skip to content

GraphQL and the UI API

Module 4 of 7 in the chapter Salesforce as an API Provider, chapter 8 of the Integration Architect course. Each module stands on its own. Previous: Many in One Call · Next: Your Own Door: Custom Apex REST

The question this module answers: When should a client ask Salesforce for exactly the data it chooses, with GraphQL, or for a record the way the screen shows it, with the UI API?

On the map: Ask for a shape On the map: Ask for a shape. One row from the map of every door into Salesforce, in module 1: the set ask for a shape, with its doors: GraphQL and the UI API. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.57.1", "built": "2026-10-31", "id": "DGM-INT-SP-11", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.5.0", "theme": "stevetecharc 1.4.0"} THE SET: WHAT THE CALLER IS DOING THE DOORS Ask for a shape the client or the org decides GraphQL exactly the fields listed · ch 8.4 UI API the whole screen for this user · ch 8.4 One set from the map of every door into Salesforce (module 1). HOW TO READ IT taught in this chapter © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Where this module sits on the map.

Module 2 gave the client two choices. Write a SOQL query and get the rows, or ask for one record by ID and get every field. Module 3 put many writes in one call. This module is about reading, and about a different idea: the client decides the shape of the answer.

GraphQL isn’t a Salesforce invention. It’s an open industry standard, and Salesforce’s GraphQL API follows its specification. Three things make it different from the REST calls in module 2:

  • One address. Every request goes to the same place, as a POST to /services/data/v68.0/graphql. The question is in the body.
  • You get only what you ask for. The client lists the fields it wants, across several objects, and nothing extra comes back.
  • It describes itself. You can ask the API what types and fields it has, so a client can discover the schema before it asks.

Salesforce puts it simply: “a single endpoint to call for all data needed in one request” (Get Started with GraphQL API (opens in a new tab), Salesforce Developers, checked 2026-10-31).

Take the crews’ mobile app at the start of a stop. It needs the Work Order’s status and address, and the items to deliver. With module 2, that’s a query for the Work Order and another for its line items, each returning whatever fields the query listed. With GraphQL, it’s one request that lists exactly those fields:

query NextStop {
uiapi {
query {
WorkOrder(where: { Partner_Delivery_Key__c: { eq: "REDROCK-8472914-1" } }) {
edges { node {
Status { value }
Street { value }
WorkOrderLineItems { edges { node { Description { value } } } }
} }
}
}
}
}

The server tailors the answer to the client. I think of it as a composite for queries, except you get to pick and choose and mix and match. On a phone, on a slow connection, that matters: fewer round trips, and a smaller answer.

It goes further than records. In my GraphQL videos, I put three kinds of question into one request: records from two unrelated objects with a filter, the schema of those objects (their fields and which ones can be created), and aggregates, the average, total and largest opportunity amount. The answer came back in under a second. And because the API describes itself, Postman read the schema and finished my field names as I typed, the same introspection a developer’s tools use.

And since API 66.0 (Spring ‘26), GraphQL can write as well as read. Mutations, which create, update and delete records, went from beta to generally available (Mutations (opens in a new tab), checked 2026-10-31). One limit to know: a mutation can’t yet create a record together with its children. For a manifest with its deliveries, module 3’s composite graph is still the tool.

One request isn’t one API call. This is where GraphQL and composite differ. Salesforce’s limits are specific (GraphQL API Query Limitations (opens in a new tab), checked 2026-10-31):

  • up to 10 subqueries in one GraphQL query, and each subquery counts as one request for rate limiting;
  • up to 2,000 records per subquery;
  • 10 records by default, unless you ask for more and page through the rest.

That last one catches people. A query that returns 10 deliveries in testing hasn’t returned all of them; it’s returned the default page. The client asks for more and follows the page cursor, the same lesson as nextRecordsUrl in module 2. And GraphQL uses the Connect API’s rate limits; go over them and the answer is 503 Service Unavailable (API Request Limits (opens in a new tab), checked 2026-10-31).

Security doesn’t change either. GraphQL honors “the object-level security and field-Level security of the context user”, so “two different users can have two different views of the GraphQL schema” (What is GraphQL API? (opens in a new tab), checked 2026-10-31). The integration user still decides what the client can see. From API 68.0, an admin also decides in Setup, under API Access Controls, whether a site’s guest user can reach GraphQL at all. Chapter 13 is about guest users and why that setting matters.

Now the opposite idea. Look at a Work Order in Salesforce. There’s a lot on the screen: the fields, in sections, in the layout the admin built; the picklist values; the related lists; the buttons. Getting all of that through module 2’s calls could take a dozen requests, and then the client still has to work out the layout and which fields this user may see.

The User Interface API does that work for you. It’s “the same API that Salesforce uses to build Lightning Experience and Salesforce for Android, iOS, and mobile web”, and it returns “data and metadata in a single response”. In Salesforce’s words: “You don’t have to worry about layouts, picklists, field-level security, or sharing” (Get Started with User Interface API (opens in a new tab), checked 2026-10-31). One call shows it:

GET /services/data/v68.0/ui-api/record-ui/0WOxx0000004C92GAE

Behind that call, Salesforce checks the user’s access, queries the record, and gets the layout and the object’s metadata. What comes back is everything the screen would show, for this user. You can see the actions too: ask for a record’s actions and you get the buttons this user could press. It’s almost like driving Salesforce’s screens through the API. And it writes as well as reads. POST /ui-api/records creates a record (Create or Clone a Record (opens in a new tab), checked 2026-10-31), with the same rules a user would meet on the screen. Ask for the layout of an object, or its full object metadata, and you get those too, each in one call.

So if a Retail Partner builds its own app to show a delivery the way Steve Trucking’s screen shows it, the UI API is the door. When Steve Trucking’s admin adds a field to the layout, the partner’s app shows it, with no change on the partner’s side. The answer follows the org.

The price is size. The UI API answer is big, because it’s everything. In my video on it, the answer for one account came back in a quarter of a second, so it isn’t slow. It’s heavy. I wouldn’t use it where every byte counts, or where the client only needs two fields. That’s GraphQL’s job.

Ask for exactly this, or ask for the screen Ask for exactly this, or ask for the screen. Top row: the crews' mobile app sends one GraphQL request, one address, the fields it lists, to Steve Trucking's org, and gets back only those fields: the Work Order's status and address and its line items, small enough for a phone. Bottom row: a Retail Partner's own app sends one UI API request, record-ui, and gets back the whole screen for that user: the data, the layout, the picklists and the actions, following the admin's changes. Underneath: both answer as the user who is calling; neither gets around field-level security or sharing. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.57.1", "built": "2026-10-31", "id": "DGM-INT-SP-03", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.5.0", "theme": "stevetecharc 1.4.0"} WHO'S ASKING THE DOOR WHAT COMES BACK The crews' mobile app at the start of a stop GraphQL one address; the request lists the fields the client chooses Only the fields it listed status, address, the items: small enough for a phone A Retail Partner's own app shows a delivery as our screen does The UI API record-ui, one record the org chooses The whole screen for this user data, layout, picklists, actions; follows the admin's changes asks returns asks returns Both answer as the user who is calling. Neither gets around field-level security or sharing. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Two ways to read. The client chooses the fields, or the org chooses the screen.

The client needsUse
A few fields from several objects, on a phone or a slow connectionGraphQL
A record exactly as Salesforce’s screen shows it, layout and allUI API
Rows for a report or a sync, in a fixed shapeREST query (module 2)
Records that belong together, written wholeComposite graph (module 3)

GraphQL and the UI API are mostly for building user interfaces outside Salesforce: mobile apps, portals, a partner’s own screens. Your Lightning web components use them too, through the GraphQL wire adapter and the UI API’s adapters. Server-to-server integrations, like Redrock’s nightly manifest, usually stay with REST and composite.

In early 2024 I made three videos on these: an introduction to GraphQL, a combined GraphQL request, and the UI API. The notes under the videos say what’s still right and what’s changed since.

STA 1.15 · Across the APIs: Salesforce GraphQL Introduction · 12:06 · published 2024-01-02 · plays from YouTube when you click it · Watch on YouTube · More videos: Salesforce Integration Architecture Videos
STA 1.16 · Across APIs: Salesforce GraphQL, Object Schema, Object Query, and Aggregate Query · 9:38 · published 2024-01-03 · plays from YouTube when you click it · Watch on YouTube · More videos: Salesforce Integration Architecture Videos
STA 1.17 · Across APIs: Salesforce UI API Can Power Your Own User Interface · 8:46 · published 2024-01-04 · plays from YouTube when you click it · Watch on YouTube · More videos: Salesforce Integration Architecture Videos
  • Who decides the shape of the answer. The client (GraphQL), the org’s layout (UI API), or a fixed query (REST).
  • How the caller pages. GraphQL returns 10 records unless asked for more; the client follows the cursor to the end.
  • What it costs against the limits. Each GraphQL subquery counts as a request; composite counts as one call. Pick by the shape of the work, then check the count.
  • Who can reach it without signing in. From API 68.0, guest access to GraphQL is a setting. Decide it on purpose.