Get Object Metadata

AVAILABLE API VERSION
API v56.0 and later
Locale available in API v60.0 and later
Picklist values available in API v65.0 and later

The objectInfos field of ObjectInfo type returns object metadata, such as whether an object is MRU enabled and whether an object is searchable or updateable. You can also retrieve picklist values when querying object metadata. The response includes metadata describing fields, child relationships, record type, and theme. You can request up to 2,000 objects in a single object metadata request.

Pass in objectInfos in the uiapi field. For example, use apiNames: ["Account"] to return the object info for the account object.

Query objectInfos field
1{
2  uiapi {
3    objectInfos(apiNames: ["Account"]) {
4      # fields
5    }
6  }
7}

Object Info Schema 

Query objectInfos with this schema.

Query objectInfos
1type UIAPI {
2   query: RecordQuery
3   objectInfos(
4      apiNames: [String]
5      locale: String
6      objectInfoInputs: [ObjectInfoInput!]
7   ): [ObjectInfo]
8}
9
10input ObjectInfoInput {apiName: String!, recordTypeIds: [ID!], fieldNames: [String!]
11}

The objectInfos type is an array of ObjectInfo types with these arguments.

  • apiNames - A list of up to 2,000 object API names of supported objects. It’s non-nullable, which means you can expect an array of zero or more items.

  • locale - Specifies which locale to use for the object’s labels. Defaults to the user’s locale. This argument is available in API v60.0 and later.

  • objectInfoInputs - Get picklist values along with object metadata without making multiple calls. This argument is available in API v65.0 and later. The objectInfoInputs argument is an array of ObjectInfoInput types with these arguments.

    • apiName - The API name of a supported object. This argument is required.
    • recordTypeIds - A list of record type IDs. An empty list, [], retrieves picklist values for all record types for the apiName object.
    • fieldNames - A list of fields to filter on. The query returns picklist values only for the fields specified. A null or empty list, [], retrieves picklist values for all picklist fields on the object.

      To retrieve object metadata without picklist values, you can either omit the objectInfoInputs argument or provide only apiName in the objectInfoInputs argument, such as objectInfoInputs: {apiName: "Account"}.

      Note

ObjectInfo Types and Fields 

The ObjectInfo type includes fields for the object metadata.

ObjectInfo Type
1type ObjectInfo {
2  ApiName: String!
3  childRelationships: [ChildRelationship]!
4  creatable: Boolean!
5  custom: Boolean!
6  defaultRecordTypeId: ID
7  deletable: Boolean!
8  dependentFields: [DependentField]!
9  feedEnabled: Boolean!
10  fields: [Field]!
11  keyPrefix: String
12  label: String
13  labelPlural: String
14  layoutable: Boolean!
15  mruEnabled: Boolean!
16  nameFields: [String]!
17  queryable: Boolean!
18  recordTypeInfos: [RecordTypeInfo]!
19  searchable: Boolean!
20  themeInfo: ThemeInfo
21  updateable: Boolean!
22  locale: String
23}

The ObjectInfo type contains these fields.

  • ApiName - A supported object. Note the different case in ApiName compared to the objectInfos type argument apiName discussed in the first section.
  • childRelationships - The object’s child relationships.
  • creatable - Indicates whether the object can be created.
  • custom - Indicates whether the object is a custom object.
  • defaultRecordTypeId - The ID for the default record type for this object. If there isn’t a default record type, this value is the master record type, which is 012000000000000AAA. If the record is a nested record (for example, in a request for an Account, the User object is a nested record), the value is null.
  • deletable - Indicates whether the object can be deleted.
  • dependentFields - The object’s dependent fields returned as a list of key and values.
  • feedEnabled - Indicates whether the object can have feeds.
  • fields - A field’s metadata. This map only contains fields relevant to the requested layout and mode. It’s non-nullable, which means you can expect an array of zero or more items.
  • keyPrefix - The key prefix for IDs of this object.
  • label - The object’s display label.
  • labelPlural - The plural form of the object’s display label.
  • layoutable - Indicates whether the object can have a layout.
  • mruEnabled - Indicates whether the object can appear in Most Recently Used lists.
  • nameFields - A list of the API names of the fields used to identify the name field for standard and custom objects. Typically there’s one name field per object, except when the object has FirstName and LastName fields.
  • queryable - Indicates whether the context user can query the object.
  • recordTypeInfos - A list of record type information about the record type. All record types are visible whether the user has access to them.
  • searchable - Indicates whether the object can be searched.
  • themeInfo - Theme information for the object.
  • updateable - Indicates whether the object can be updated.
  • locale - The locale for the object’s labels. This field is available in API v60.0 and later.

ChildRelationship 

The ChildRelationship type represents the child relationship on a parent object. For example, you can return data about related object records on a record’s detail page. GraphQL API enables you to query the object info of all the child relationships by using the objectInfo field.

ChildRelationship Type
1type ChildRelationship {
2  childObjectApiName: String!
3  fieldName: String
4  junctionIdListNames: [String]!
5  junctionReferenceTo: [String]!
6  objectInfo: ObjectInfo
7  relationshipName: String

The ChildRelationship type contains these fields.

  • childObjectApiName - The API name of the child object.
  • fieldName - The field on the child object that contains the reference to the parent object. Salesforce uses a reference field to store the ID of the related parent record.
  • junctionIdListNames - The names of the JunctionIdList fields associated with an object. Each ID is a polymorphic key, which is an ID that can refer to more than one type of object.
  • junctionReferenceTo - A collection of object names that the polymorphic keys in the junctionIdListNames property can reference.
  • objectInfo - The object’s metadata.
  • relationshipName - The name of the relationship. The name is the plural form of the child object name. For example, Account has a relationshipName for each object: Assets, Cases, and Contacts.

DependentField 

The DependentField type contains information about a dependent field that relies on the value of a controlling field. For example, a picklist with a list of cities depends on a controlling picklist field that shows a list of countries. Selecting a value on a controlling field filters down the values in a dependent field.

DependentField Type
1type DependentField {
2   controllingField: String!
3   dependentFields: [String]!
4}

The DependentField type contains these fields.

  • controllingField - Standard and custom checkboxes and picklists with at least one and less than 300 values can be controlling fields.
  • dependentFields - A list of dependent fields, such as custom picklists or multi-select picklists.

Queries return dependent fields as a list of keys and values.

Example dependentFields Response
1"dependentFields" : [
2   {
3        "controllingField" : "Continents__c",
4        "dependentFields" : ["Countries__c"]
5   },
6   {
7        "controllingField" : "Countries__c",
8        "dependentFields" : ["Cities__c"]
9   },
10        "controllingField" : "Cities__c",
11        "dependentFields" : [] # Cities__c doesn't correspond to any dependent fields
12]

Field 

The Field interface defines a field’s metadata.

Field Interface
1type Field {
2  ApiName: String!
3  calculated: Boolean!
4  compound: Boolean!
5  compoundComponentName: String
6  compoundFieldName: String
7  controllerName: String
8  controllingFields: [String]!
9  creatable: Boolean!
10  custom: Boolean!
11  dataType: DataType
12  defaultedOnCreate: Boolean!
13  extraTypeInfo: FieldExtraTypeInfo
14  filterable: Boolean!
15  filteredLookupInfo: FilteredLookupInfo
16  highScaleNumber: Boolean!
17  htmlFormatted: Boolean!
18  inlineHelpText: String
19  label: String
20  nameField: Boolean!
21  polymorphicForeignKey: Boolean
22  precision: Int
23  reference: Boolean!
24  referenceTargetField: String
25  referenceToInfos: [ReferenceToInfo]!
26  relationshipLabel: String
27  relationshipName: String
28  required: Boolean!
29  scale: Int
30  searchPrefilterable: Boolean
31  sortable: Boolean!
32  updateable: Boolean!
33}

The Field interface contains these fields.

  • ApiName - The API name for this field.
  • calculated - Indicates whether the field is a custom formula field.
  • compound - Indicates whether the field is a top-level compound field. If the dataType is Location, this value is usually false.
  • compoundComponentName - If the field is a component field of a compound field, the value is the normalized component name, otherwise the value is null. For example, if the field represents BillingStreet of an Address compound field, this value contains Street.
  • compoundFieldName - If the field is a component field of a compound field, compoundFieldName contains the top-level compound field. Otherwise, the value is null.
  • controllerName - If the field is a dependent picklist, controllerName is the name of the field that controls the values of the picklist.
  • controllingFields - If the field is a dependent picklist, controllingFields is a list of fields that control the values in the picklist. When there’s a hierarchy of controlling fields, the list starts with the immediate parent and moves up the tree.
  • creatable - Indicates whether the field can be created.
  • custom - Indicates whether the field is a custom field.
  • dataType - The field type that the DataType enum provides.
  • defaultedOnCreate - Indicates whether the field is automatically assigned a default value during record creation. This field is available in API v67.0 and later.
  • extraTypeInfo - Data type information that the FieldExtraTypeInfo enum provides.
  • filterable - Indicates whether the field is filterable. If true, then you can specify this field in the where argument.
  • filteredLookupInfo - If the field is a reference field type with a lookup filter, this value contains the lookup information. See FilteredLookupInfo.
  • highScaleNumber - Indicates whether the field stores numbers to 8 decimal places regardless of what’s specified in the field details.
  • htmlFormatted - Indicates whether the field is formatted for HTML and is encoded for display in HTML. Also indicates whether a field is a custom formula field that has an IMAGE text function.
  • inlineHelpText - The text that appears in the field-level help hover text.
  • label - Text label that appears next to the field in the Salesforce user interface.
  • nameField - Indicates whether the field is a name field.
  • polymorphicForeignKey - Indicates whether the field is a foreign key over a domain of multiple objects.
  • precision - For double fields, indicates the maximum number of digits that can be stored, on both sides of the decimal point.
  • reference - Indicates whether the field is a foreign key to another record. A reference field contains an ID value that points to a unique record (usually the parent record) on another object.
  • referenceTargetField - For indirect lookup relationships on external objects, this property is the target custom field of the referenced object.
  • referenceToInfos - For fields that refer to other objects, this list includes information about the object types and name fields of the referenced objects. See ReferenceToInfo.
  • relationshipLabel - The localized label of the relationshipName field.
  • relationshipName - The name of the relationship, if this relationship is a master-detail relationship field.
  • required - Indicates whether the field is required when creating or editing a record.
  • scale - For double fields, indicates the number of digits to the right of the decimal point.
  • searchPrefilterable - Indicates whether you can include a foreign key (relationship field) in the where argument.
  • sortable - Indicates whether the field is sortable. If true, then you can specify the field in an orderBy argument.
  • updateable - Indicates whether the field can be edited.

Field Types 

Two field types, StandardField and PicklistField, implement the Field interface.

StandardField 

The StandardField type implements the Field interface and contains the same fields as the Field interface.

PicklistField 

The PicklistField type implements the Field interface, contains the same fields as the Field interface, and has an additional picklistValuesByRecordTypeIDs field.

PicklistField Type
1type PicklistField {
2  //same fields as Field interface
3  picklistValuesByRecordTypeIDs: [PicklistValueByRecordTypeIDs]
4}

For picklist fields, the picklistValuesByRecordTypeIDs field is a list of picklist values by record types.

PicklistValueByRecordTypeIDs 

The PicklistValueByRecordTypeIDs type describes all the picklist values for a record.

PicklistValueByRecordTypeIDs
1type PicklistValueByRecordTypeIDs {
2  recordTypeID: String!
3  controllerValues: [ControllerValues!]
4  picklistValues: [PicklistValuesValues!]
5  defaultValue: PicklistValues
6}

The PicklistValueByRecordTypeIDs type has these fields.

  • recordTypeID — The ID of the record type.
  • controllerValues — The values in a controlling field that determine which dependent picklist values are available in a dependent picklist relationship.
  • picklistValues — The picklist values for the record.
  • defaultValue — The default picklist value for the record.

ControllerValues 

The ControllerValues type describes the values in a controlling field that determine which dependent picklist values are available in a dependent picklist relationship.

ControllerValues
1type ControllerValues {
2  value: String
3  index: Int
4}

The ControllerValues type has these fields.

  • value — The controller field value.
  • index — The index that determines which dependent picklist value is valid for each controller field value.

PicklistValues 

The PicklistValues type describes the picklist values.

PicklistValues
1type PicklistValues {
2  value: String
3  label: String
4  validFor: [Int]
5  attributes: PicklistAttributes
6}

The PicklistValues type has these fields.

  • value — The value of the picklist item.
  • label — The label of the picklist item.
  • validFor — Indicates which controlling field values a dependent picklist value is valid for.
  • attributes — The attributes of the picklist item.

PicklistAttributes 

The PicklistAttributes type describes the attributes of the picklist item.

PicklistAttributes
1type PicklistAttributes {
2  connectDisplayName: String
3  internalName: String
4}

The PicklistAttributes type has these fields.

  • connectDisplayName — The display name of the picklist attribute.
  • internalName — The internal name of the picklist attribute.

FilteredLookupInfo 

The FilteredLookupInfo type describes lookup filter information. If the type is null, the field it describes is a dependent lookup.

FilteredLookupInfo
1type FilteredLookupInfo {
2  controllingFields: [String]!
3  dependent: Boolean!
4  optionalFilter: Boolean!
5}

The FilteredLookupInfo type contains these fields.

  • controllingFields - For dependent picklists, controllingFields returns a list of fields that control the values in the picklist.
  • dependent - Indicates whether the field depends on another field.
  • optionalFilter - Indicates whether the lookup filter is optional.

ReferenceToInfo 

The ReferenceToInfo type describes information about a reference field’s referenced types and the name field names of those types.

ReferenceToInfo Type
1type ReferenceToInfo {
2  ApiName: String!
3  nameFields: [String]!
4  objectInfo: ObjectInfo
5}

The ReferenceToInfo type contains these fields.

  • ApiName - The object API name of a type that a relationship references.
  • nameFields - A collection of names of the name fields for this object type.
  • objectInfo - The object’s metadata.

ThemeInfo 

The ThemeInfo type describes color and icon information for a theme.

ThemeInfo Type
1type ThemeInfo {
2  color: String
3  iconUrl: String
4}

The ThemeInfo type contains these fields.

  • color - Color information for a theme
  • iconUrl - Icon URL

RecordTypeInfo 

The RecordTypeInfo type describes information about a record type.

RecordTypeInfo
1type RecordTypeInfo {
2  available: Boolean
3  defaultRecordTypeMapping: Boolean
4  master: Boolean
5  name: String
6  recordTypeId: String
7}

The RecordTypeInfo type contains these fields.

  • available - Indicates whether this record type is available to the context user when creating a record.
  • defaultRecordTypeMapping - Indicates whether this record type mapping is the default for the associated object.
  • master - Indicates whether this record type is the master record type. The master record type is the default record type that’s used when a record has no custom record type associated with it.
  • name - The record type’s label name.
  • recordTypeId - The ID of the record type.

Enumeration Types 

The Field interface contains several enum definitions for the dataType and extraTypeInfo fields.

DataType 

The DataType enumeration describes the data type for the field.

DataType Enum
1enum DataType {
2  ADDRESS
3  ANYTYPE
4  BASE64
5  BOOLEAN
6  COMBOBOX
7  COMPLEXVALUE
8  CURRENCY
9  DATE
10  DATETIME
11  DOUBLE
12  EMAIL
13  ENCRYPTEDSTRING
14  INT
15  JSON
16  JUNCTIONLIST
17  LOCATION
18  LONG
19  MULTIPICKLIST
20  PERCENT
21  PHONE
22  PICKLIST
23  REFERENCE
24  STRING
25  TEXTAREA
26  TIME
27  URL
28}

FieldExtraTypeInfo 

The FieldExtraTypeInfo enumeration describes data type information.

FieldExtraTypeInfo Enum
1enum FieldExtraTypeInfo {
2  EXTERNAL_LOOKUP
3  IMAGE_URL
4  INDIRECT_LOOKUP
5  PERSONNAME
6  PLAINTEXTAREA
7  RICHTEXTAREA
8  SWITCHABLE_PERSONNAME
9}

See Also 

Get Object Metadata Examples