| AVAILABLE API VERSION |
|---|
| API v56.0 and later |
| Event and task beta available in API v59.0–65.0 |
| Event and task generally available in API v66.0 and later |
GraphQL has the same limitations as SOQL. When working with GraphQL API queries, consider the following limitations.
- Each GraphQL query can contain up to 10 subqueries.
- Each subquery counts as one request for rate limiting.
- Each subquery can return up to 2000 records within the same GraphQL query.
- By default, the first 10 records are returned. You can use pagination information to retrieve additional records.
- You can query only objects that User Interface API supports.
note: Some fields are not filterable using the where filter. To find out if a field is supported for filtering, see the Object Reference for the Salesforce Platform. For example, the NewValue and OldValue fields on the CaseHistory object don't include "Filter" in the Properties section and aren't supported for filtering. If you attempt to pass in an unsupported field to the where filter, you get a "Field 'FieldName' in type 'ObjectName' is undefined" error.
Relationship Queries
An object must have a parent or child relationship with another object to form a query similar to an SOQL join. Limitations for relationship queries are discussed in the next few sections.
Child-to-Parent Relationships
Child-to-parent relationships follow these limits.
- A query can specify up to 55 child-to-parent relationships. A custom object allows up to 40 relationships, so you can reference all the child-to-parent relationships for a custom object in one query.
- You can specify up to five levels in a child-to-parent relationship.
- A child relationship name can't be the same as a parent relationship name within an object.
This example shows three levels of child-to-parent relationship, which is Contact.Account.Owner.FirstName.
query {
uiapi {
query {
Contact {
edges {
node {
Id
Name { value }
Account { # first level of child-to-parent relationship
Owner { # second level
FirstName { value } # third level
}
}
}
}
}
}
}
}
Additionally, consider these differences between API versions.
- In API version 57.0 and earlier, you can specify up to two levels of child-to-parent relationship in a query.
- In API version 58.0 and later, you can specify up to five levels of child-to-parent relationship for standard and custom objects.
Parent-to-Child Relationships
Parent-to-child relationships follow these limits.
- A query can specify up to 20 parent-to-child relationships.
- You can specify one level in a parent-to-child relationship.
- A parent relationship name can't be the same as a child relationship name within an object.
This example shows a parent-to-child relationship, which is Account.Contacts.
query {
uiapi {
query {
Account {
edges {
node {
Id
Name { value }
Contacts { # parent-to-child relationship
edges {
node {
Owner { # child-to-parent relationship
CreatedBy { # child-to-parent relationship
Name {
value
}
}
}
}
}
}
}
}
}
}
}
}
If you’re querying Account, the fields you select can specify only the Contact or other objects at that level. The query can’t specify a child object of Contact.
Semi-Join and Anti-Join Queries
GraphQL API follows SOQL restrictions on semi-join and anti-join queries.
- You can use up to two
ninandninqoperators in awhereargument. Aninandninqoperator can support up to twoinorninoperators. - You can't use the
neoperator with semi-joins and anti-joins. Using this operator converts a semi-join to an anti-join and vice versa. Instead, write the query in the appropriate semi-join or anti-join form.
Main Query Limits
Consider these restrictions on the where argument of a semi-join or anti-join query.
- You must use a single ID for the semi-join or anti-join query.
- The ID in the
whereargument that's used in the semi-join or anti-join can't use relationships.
This example uses a single ID in a semi-join to return contact names associated with accounts whose ownership is public.
query {
uiapi {
query {
Contact (where: {
AccountId: { inq: {
Account: { Ownership: { eq: "Public" } },
ApiName:"Id" },
}
}) {
edges {
node {
Id
Name {
value
}
}
}
}
}
}
}
The previous query is similar to this SOQL statement.
SELECT Id, Name
FROM Contact
WHERE AccountId
IN (
SELECT Id FROM Account
WHERE Ownership = 'Public'
)
Subquery Limits
A subquery must query a field referencing the same object type as the main query. For example, use the Id field on the where argument followed by ApiName:"AccountId"in the inq operator. Using Account.Id (dot notation) instead of AccountId isn't supported.
This example returns specific accounts using AccountId as the selected field in the subquery, in which the contacts' last names start with "B".
query {
uiapi {
query {
Account (where: {
Id: { inq: {
Contact: { LastName: { like: "B%" } },
ApiName:"AccountId" },
}
}) {
edges {
node {
Id
Name {
value
}
}
}
}
}
}
}
The previous query is similar to this SOQL statement.
SELECT Id, Name
FROM Account
WHERE Id IN
(
SELECT AccountId
FROM Contact
WHERE LastName LIKE 'B%'
)
There's no limit on the number of records matched in a subquery. By default, the first 10 records are returned. You can use the pagination information to retrieve additional records.
query {
uiapi {
query {
Account (first:50, where: {
Id: { inq: {
Contact: { LastName: { like: "B%" } },
ApiName:"AccountId" },
}
}) {
edges {
node {
Id
Name {
value
}
}
}
}
}
}
}
The selected field in a subquery must be a reference to a different object, and can't traverse relationships. In the previous example, the main query selects from accounts and the subquery selects from contacts.
You can’t query on the same object in a subquery as in the main query. Instead of selecting from the same object in the main query and subquery, you can rewrite a semi-join query using the Parent field.
query {
uiapi {
query {
Account ( where: {
Parent: { Name: { like: "United%" } }
}) {
edges {
node {
Id
Name {
value
}
}
}
}
}
}
}
The previous query is similar to this SOQL statement.
SELECT Id, Name
FROM Account
WHERE Parent.Name LIKE 'United%'
A semi-join or anti-join statement:
- Can’t be nested in another semi-join or anti-join statement
- Can’t be used in a subquery
whereargument.
A subquery can’t be used with:
- The
oroperator - The
orderByoperator
Multiple Semi-Joins and Anti-Joins
You can combine semi-join or anti-join clauses in a query using the inq or ninq functions in a where argument. However, you can use only up to two subqueries in a single semi-join or anti-join queries.
This example includes 2 semi-join filters that return accounts if they have an associated opportunity and an associated case that has its Priority field set to "High".
query {
uiapi {
query {
Account (where: { and: [{
Id: { inq: {
Opportunity: {},
ApiName:"AccountId" },
},
Id: { inq: {
Case : { Priority : { eq : "High" } },
ApiName:"AccountId" }
}
}] }) {
edges {
node {
Id
Name {
value
}
}
}
}
}
}
}
The previous query is similar to this SOQL statement.
SELECT Id, Name
FROM Account
WHERE Id IN
(
SELECT AccountId
FROM Opportunity
)
AND Id IN
(
SELECT AccountId
FROM Case
WHERE Priority = 'High'
)
Object-Specific Limitations
Only the UI API supported objects are available in GraphQL API. Certain supported objects come with additional limitations.
Note Object Limitations
The Note object has these limitations.
- You can't query the Note object in subqueries.
- You can query the Note object but you can't evaluate the body of a note, such as filtering on
Note.Bodyby using theeqorlikeoperator. You also can’t filter against the content of textarea fields, blobs, or S-control components in any object.
You can return the content of the body of the note like this.
query {
uiapi {
query {
Account ( where: { Name: { like: "Edge%" }
}) {
edges {
node {
Notes {
edges {
node {
Body {value}
}
}
}
Id
Name {
value
}
}
}
}
}
}
}
The previous query is similar to this SOQL statement.
SELECT Name, (SELECT Note.Body FROM Account.Notes) FROM Account
WHERE Name LIKE 'Edge%'
You can also return all account names and the owner ID for any notes associated with the account.
query {
uiapi {
query {
Account ( where: { Name: { like: "Edge%" }
}) {
edges {
node {
Notes {
edges {
node {
OwnerId { value }
}
}
}
Id
Name { value }
}
}
}
}
}
}
The previous query is similar to this SOQL statement.
SELECT Account.Name, (SELECT Note.OwnerId FROM Account.Notes) FROM Account
External Objects Limitations
External objects have these limitations.
- A subquery that involves external objects can fetch up to 1,000 rows of data.
- Each query can have up to 4 joins across external objects and other types of objects. Each join requires a separate round trip to the external system when executing the query. Expect longer response times for each join in a query.
- External objects don’t support the
orderByargument in relationship queries. This limit applies only when the external data is accessed via the OData 2.0 adapter for Salesforce Connect.