GraphQL API

See what’s new with GraphQL API.

Use the Managed Content GraphQL API to search for Salesforce CMS content
Access the Managed Content API family through the managed_content field on the Query operation type. See Use the New Managed Content GraphQL API to Search for CMS Content.
Use platform capabilities to complement record queries
The platform field on the UIAPI type provides capabilities to:
  • Resolve user-permission grants for the current user
  • Resolve authenticated file-asset URLs
  • Resolve canonical URLs for static resources
  • Get the current user’s internationalization properties
  • Resolve custom and standard label values in the current user’s locale
This schema is for platform.
type UIAPI {
  platform: Platform!
}

type Platform {
  userPermissions(names: [String!]!): [UserPermission]!
  customPermissions(names: [String!]!): [CustomPermission]!
  contentAssetUrls(names: [String!]!): [ContentAssetUrl]!
  resourceUrls(names: [String!]!): [ResourceUrl]!
  i18n: I18nData
  labels(
    namespace: String = "c"
    names: [String!]!
    locale: String
    fallback: LabelFallback
  ): [LabelResult]!
}
This example checks whether the current user has the specified permissions.
{
  uiapi {
    platform {
      userPermissions(names: ["ManageUsers", "ViewSetup"]) {
        name
        hasAccess
      }
      customPermissions(names: ["My_Custom_Permission"]) {
        name
        hasAccess
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "platform": {
        "userPermissions": [
          {
            "name": "ManageUsers",
            "hasAccess": false
          },
          {
            "name": "ViewSetup",
            "hasAccess": true
          }
        ],
        "customPermissions": [
          {
            "name": "My_Custom_Permission",
            "hasAccess": true
          }
        ]
      }
    }
  },
  "errors": []
}
This example resolves the URLs for two content assets.
{
  uiapi {
    platform {
      contentAssetUrls(names: ["companyLogo", "acme__heroBanner"]) {
        name
        url
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "platform": {
        "contentAssetUrls": [
          {
            "name": "companyLogo",
            "url": "https://example.my.salesforce.com/file-asset/companyLogo?v=1"
          },
          {
            "name": "acme_heroBanner",
            "url": "https://example.my.salesforce.com/file-asset/acme__heroBanner?v=3"
          }
        ]
      }
    }
  },
  "errors": []
}
This example resolves the URLs for two static resources.
{
  uiapi {
    platform {
      resourceUrls(names: ["myResource", "acme__logo"]) {
        name
        url
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "platform": {
        "resourceUrls": [
          {
            "name": "myResource",
            "url": "/resource/1234567890000/myResource"
          },
          {
            "name": "acme__logo",
            "url": "/resource/1234567890001/acme__logo"
          }
        ]
      }
    }
  },
  "errors": []
}
This example gets the current user’s locale, time zone, and date format patterns.
{
  uiapi {
    platform {
      i18n {
        lang
        locale
        timeZone
        firstDayOfWeek
        dateTime {
          shortDateFormat
          mediumDateFormat
          longDateFormat
          shortTimeFormat
        }
        number {
          currencySymbol
          decimalSeparator
          groupingSeparator
        }
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "platform": {
        "i18n": {
          "lang": "en",
          "locale": "en_US",
          "timeZone": "America/Los_Angeles",
          "firstDayOfWeek": 0,
          "dateTime": {
            "shortDateFormat": "M/d/yyyy",
            "mediumDateFormat": "MMM d, yyyy",
            "longDateFormat": "MMMM d, yyyy",
            "shortTimeFormat": "h:mm a"
          },
          "number": {
            "currencySymbol": "$",
            "decimalSeparator": ".",
            "groupingSeparator": ","
          }
        }
      }
    }
  },
  "errors": []
}
This example gets two custom labels in French.
{
  uiapi {
    platform {
      labels(names: ["greeting", "submit_button"], locale: "fr", fallback: USER_DEFAULT) {
        namespace
        name
        value
        resolvedLocale
        wasFallback
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "platform": {
        "labels": [
          {
            "namespace": "c",
            "name": "greeting",
            "value": "Bonjour",
            "resolvedLocale": "fr",
            "wasFallback": false
          },
          {
            "namespace": "c",
            "name": "submit_button",
            "value": "Submit",
            "resolvedLocale": "en",
            "wasFallback": true
          }
        ]
      }
    }
  },
  "errors": []
}
Improved mutation field references
You can chain multiple mutation operations in a single request by using field references. GraphQL now supports two new field reference patterns in mutation chaining. Assuming ref is the name or alias of a previous mutation operation from the same request, this table shows the new patterns.
Reference Description
@{ref.Record.Id} Explicit record ID reference.
@{ref.Record.FieldName.value} GraphQL field reference. For example, Name { value } in a GraphQL query is @{ref.Record.Name.value}.
Previously, @{ref} was the only supported pattern.
This example chains the creation of an account, contact, and opportunity in a single request and uses all the supported field reference patterns.
mutation CreateAccountAndContact {
  uiapi(input: { allOrNone: false }) {
    AccountCreate(input: {
      Account: {
        Name: "Mutation Fun"
      }
    }) {
      Record {
        Id                              # referenced in 'OpportunityCreate'
        Name { value }                  # referenced in 'ContactCreate'
      }
    }
    ContactCreate(input: {
      Contact: {
        MailingCity: "Paris"
        LastName: "@{AccountCreate.Record.Name.value}"
        AccountId: "@{AccountCreate}"   # equivalent to AccountCreate.Record.Id
      }
    }) {
      Record {
        Id
        LastName { value }              # referenced in 'OpportunityCreate'
        MailingCity { value }           # referenced in 'OpportunityCreate'
      }
    }
    OpportunityCreate(input: {
      Opportunity: {
        Name: "@{ContactCreate.Record.LastName.value}"            # 'ContactCreate' reference
        Description: "@{ContactCreate.Record.MailingCity.value}"  # 'ContactCreate' reference
        AccountId: "@{AccountCreate.Record.Id}"                   # 'AccountCreate' reference
        StageName: "Value Proposition"
        CloseDate: "2026-12-31"
      }
    }) {
      Record {
        Id
        AccountId { value }
        Name { value }
        Description { value }
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "AccountCreate": {
        "Record": {
          "Id": "001LT000011naPRYAY",
          "Name": {
            "value": "Mutation Fun"
          }
        }
      },
      "ContactCreate": {
        "Record": {
          "Id": "003LT00000ArlizYAB",
          "LastName": {
            "value": "Mutation Fun"
          },
          "MailingCity": {
            "value": "Paris"
          }
        }
      },
      "OpportunityCreate": {
        "Record": {
          "Id": "006LT000005R4HZYA0",
          "AccountId": {
            "value": "001LT000011naPRYAY"
          },
          "Name": {
            "value": "Mutation Fun"
          },
          "Description": {
            "value": "Paris"
          }
        }
      }
    }
  },
  "errors": [],
  "extensions": {}
}
Chain queries together in a single request
You can chain multiple query operations in a single request by using field references. Assuming ref is the name or alias of a previous query operation from the same request, this table shows the supported field reference patterns.
Reference Description
@{ref.FieldName} First-level field reference
@{ref.FieldName.value} First-level field value reference
@{ref.edges[*].node.FieldName} Field reference in a list
@{ref.edges[*].node.FieldName.value} Field value reference in a list
@{ref.edges[ListItemNumber].node.FieldName} Field reference with a specific list item number, starting with 0
@{ref.edges[ListItemNumber].node.FieldName.value} Field value reference with a specific list item number, starting with 0
This example chains the query of the current user to the query of all the accounts the user owns in a single request.
query queries {
  uiapi {
    currentUser {
      Id
      Name { value }
      Username { value }
    }
    query {
      allAccounts: Account(
        where: { OwnerId: { eq: "@{currentUser.Id}" } }
      ) {
        edges {
          node {
            Id
            Name { value }
            Description { value }
            Owner {
              Id
              Name { value }
            }
          }
        }
      }
    }
  }
}
The response looks like this.
{
  "data": {
    "uiapi": {
      "currentUser": {
        "Id": "005LT00000472u1YAA",
        "Name": {
          "value": "Your Name Here"
        },
        "Username": {
          "value": "yournamehere@yourorg.com"
        }
      },
      "query": {
        "allAccounts": {
          "edges": [
            {
              "node": {
                "Id": "001LT00000DzUzNYAV",
                "Name": {
                  "value": "Global Media"
                },
                "Description": {
                  "value": "GBM is the worldwide leader in technology news and information."
                },
                "Owner": {
                  "Id": "005LT00000472u1YAA",
                  "Name": {
                    "value": "Your Name Here"
                  }
                }
              }
            },
            {
              "node": {
                "Id": "001LT00000DzUzPYAV",
                "Name": {
                  "value": "Second Account"
                },
                "Description": {
                  "value": "Second account description."
                },
                "Owner": {
                  "Id": "005LT00000472u1YAA",
                  "Name": {
                    "value": "Your Name Here"
                  }
                }
              }
            },
            {
              "node": {
                "Id": "001LT00000DzUzSYAV",
                "Name": {
                  "value": "Third Account"
                },
                "Description": {
                  "value": null
                },
                "Owner": {
                  "Id": "005LT00000472u1YAA",
                  "Name": {
                    "value": "Your Name Here"
                  }
                }
              }
            }
          ]
        }
      }
    }
  },
  "errors": [],
  "extensions": {}
}
Discover whether a field is automatically assigned a default value when a record is created
The Field interface has a new defaultedOnCreate field. When you query defaultedOnCreate on a record, you get a boolean value indicating whether the field is automatically assigned a default value when a record is created.
Get a field's localized relationship name
The Field interface has a new relationshipLabel field. When you query relationshipLabel on a record, you get the localized label for the relationshipName field.
Event and task objects are generally available
User Interface API now supports event and task objects, so these objects are generally available in GraphQL API.