# Get Object Metadata Examples

| 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 |

## Query Account Object Metadata

This example fetches the metadata for the Account object.

```sfdocs-code {"lang":"graphql", "title": "Query Account ObjectInfo", "src": "" }
{
  uiapi {
    objectInfos(apiNames: ["Account"]) {
      ApiName
      childRelationships {
        fieldName
        childObjectApiName
        junctionIdListNames
        junctionReferenceTo
        relationshipName

      }
      createable
      custom
      defaultRecordTypeId
      deletable
      dependentFields {
        controllingField
        dependentFields
      }
      feedEnabled
      fields {
        ApiName
        calculated
        compound
        compoundComponentName
        controllerName
        controllingFields
        createable
        custom
        dataType
        extraTypeInfo
        filterable
        filteredLookupInfo {
          controllingFields
          dependent
          optionalFilter
        }
        highScaleNumber
        htmlFormatted
        inlineHelpText
        label
        nameField
        polymorphicForeignKey
        precision
        reference
        referenceToInfos {
          ApiName
          nameFields
        }
        relationshipName
        referenceTargetField
        scale
        sortable
        searchPrefilterable
        updateable
      }
      keyPrefix
      label
      labelPlural
      layoutable
      mruEnabled
      nameFields
      queryable
      recordTypeInfos {
        name
        recordTypeId
      }
      searchable
      themeInfo {
        color
        iconUrl
      }
      updateable
    }
  }
}
```

The previous query returns this response.

```sfdocs-code {"lang":"json", "title": "Response for Account ObjectInfo Query", "src": "" }
{
  "data": {
    "uiapi": {
      "objectInfos": [
        {
          "ApiName": "Account",
          "childRelationships": [
            {
              "fieldName": "ParentId",
              "childObjectApiName": "Account",
              "junctionIdListNames": [],
              "junctionReferenceTo": [],
              "relationshipName": "ChildAccounts"
            },
            //...truncated for display
          "createable": true,
          "custom": false,
          "defaultRecordTypeId": null,
          "deletable": true,
          "dependentFields": [],
          "feedEnabled": true,
          "fields": [
            {
              "ApiName": "ShippingLatitude",
              "calculated": false,
              "compound": false,
              "compoundComponentName": "ShippingAddress",
              "controllerName": null,
              "controllingFields": [],
              "createable": true,
              "custom": false,
              "dataType": "DOUBLE",
              "extraTypeInfo": null,
              "filterable": true,
              "filteredLookupInfo": null,
              "highScaleNumber": false,
              "htmlFormatted": false,
              "inlineHelpText": null,
              "label": "Shipping Latitude",
              "nameField": false,
              "polymorphicForeignKey": false,
              "precision": 18,
              "reference": false,
              "referenceToInfos": [],
              "relationshipName": null,
              "referenceTargetField": null,
              "scale": 15,
              "sortable": true,
              "searchPrefilterable": false,
              "updateable": true
            },
            //...truncated for display
            "keyPrefix": "001",
            "label": "Account",
            "labelPlural": "Accounts",
            "layoutable": true,
            "mruEnabled": true,
            "nameFields": [
              "Name"
            ],
            "queryable": true,
            "recordTypeInfos": [
              {
                "name": "Master",
                "recordTypeId": "012000000000000AAA"
              }
            ],
            "searchable": true,
            "themeInfo": {
              "color": "7F8DE1",
              "iconUrl": "https://www.example.com/img/account_120.png"
            },
            "updateable": true
          }
       ]
     }
  },
  "errors": []
}
```

## Query Account Object Labels Using a Locale

This example gets account labels in French.

```sfdocs-code {"lang":"graphql", "title": "Query objectInfos with locale", "src": "" }
query accounts {
    uiapi {
         objectInfos(apiNames: ["Account"], locale: "fr_FR") {
           ApiName
           locale
           fields {
             label
           }
         }
    }
}
```

The previous query returns this response.

```sfdocs-code {"lang":"graphql", "title": "Response for objectInfos with locale Query", "src": "" }
{
  "data": {
    "uiapi": {
      "objectInfos": [
        {
          "ApiName": "Account",
          "locale": "fr_FR",
          "fields": [
            {
              "label": "Date de dernière modification"
            },
            {
              "label": "Ville de facturation"
            },
            {
              "label": "Jigsaw Company ID"
            },
            {
              "label": "SLA"
            },
          :
          :
          ]
        }
      ]
    }
  }
}
```

## Query Picklist Values for a Record Type

This example gets all picklist values for the Account object for a specified record type ID.

```sfdocs-code {"lang":"graphql", "title": "Query Picklist Values for a Record Type", "src": "" }
query GetPicklistValuesByRecordType {
  uiapi {
    objectInfos(objectInfoInputs: {
      apiName: "Account",
      recordTypeIDs: ["012000000000000AAA"],
      fieldNames: []
    }) {
      apiName
      fields {
        apiName
        ... on PicklistField {
          picklistValuesByRecordTypeIDs {
            recordTypeID
            controllerValues {
              value
            }
            picklistValues {
              value
            }
          }
        }
      }
    }
  }
}
```

The previous query returns this response.

```sfdocs-code {"lang":"graphql", "title": "Response for Picklist Values for a Record Type Query", "src": "" }
{
  "data": {
    "uiapi": {
      "objectInfos": [
        {
          "apiName": "Account",
          "fields": [
            {
              "apiName": "Industry",
              "picklistValuesByRecordTypeIDs": [
                {
                  "recordTypeID": "012000000000000AAA",
                  "controllerValues": [],
                  "picklistValues": [
                    { "value": "Agriculture" },
                    { "value": "Apparel" },
                    ...
                  ]
                }
              ]
            },
            ...
          ]
        }
      ]
    }
  }
}
```

## Query Picklist Values for Multiple Record Types

This example gets all picklist values for two record type IDs and filtered by a field name.

```sfdocs-code {"lang":"graphql", "title": "Query Picklist Values for Multiple Record Types", "src": "" }
query GetFilteredPicklistValues {
  uiapi {
    objectInfos(objectInfoInputs: {
      apiName: "Account",
      recordTypeIDs: ["012000000000000AAA", "012xx0000006ZD2AAM"],
      fieldNames: ["Industry"]
    }) {
      apiName
      fields {
        apiName
        ... on PicklistField {
          picklistValuesByRecordTypeIDs {
            recordTypeID
            controllerValues {
              value
            }
            picklistValues {
              value
            }
          }
        }
      }
    }
  }
}
```

The previous query returns this response.

```sfdocs-code {"lang":"graphql", "title": "Response for Picklist Values with Multiple Record Types Query", "src": "" }
{
  "data": {
    "uiapi": {
      "objectInfos": [
        {
          "apiName": "Account",
          "fields": [
            {
              "apiName": "Industry",
              "picklistValuesByRecordTypeIDs": [
                {
                  "recordTypeID": "012000000000000AAA",
                  "controllerValues": [],
                  "picklistValues": [
                    { "value": "Agriculture" },
                    { "value": "Apparel" },
                    ...
                  ]
                },
                {
                  "recordTypeID": "012xx0000006ZD2AAM",
                  "controllerValues": [],
                  "picklistValues": [
                    { "value": "Agriculture" },
                    { "value": "Apparel" },
                    ...
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  }
}
```

## Query Account Child Relationships

This example fetches all the child relationships for the Account object.

```sfdocs-code {"lang":"graphql", "title": "Query childRelationships on Account", "src": "" }
{
  uiapi {
    objectInfos(apiNames: ["Account"]) {
      childRelationships {
        objectInfo {
          ApiName
          createable
          custom
          defaultRecordTypeId
          deletable
          feedEnabled
          keyPrefix
          label
          labelPlural
          layoutable
          mruEnabled
          nameFields
          queryable
          searchable
          updateable
        }
      }
    }
  }
}
```

The previous query returns this response.

```sfdocs-code {"lang":"json", "title": "Response for Account childRelationship Query", "src": "" }
{
  "data": {
    "uiapi": {
      "objectInfos": [
        {
          "childRelationships": [
            {
              "objectInfo": {
                "ApiName": "Account",
                "createable": true,
                "custom": false,
                "defaultRecordTypeId": null,
                "deletable": true,
                "feedEnabled": true,
                "keyPrefix": "001",
                "label": "Account",
                "labelPlural": "Accounts",
                "layoutable": true,
                "mruEnabled": true,
                "nameFields": [
                  "Name"
                ],
                "queryable": true,
                "searchable": true,
                "updateable": true
              }
            },
            {
              "objectInfo": {
                "ApiName": "AccountChangeEvent",
                "createable": false,
                "custom": false,
                "defaultRecordTypeId": null,
                "deletable": false,
                "feedEnabled": false,
                "keyPrefix": "1CE",
                "label": "Account Change Event",
                "labelPlural": "Account Change Event",
                "layoutable": false,
                "mruEnabled": false,
                "nameFields": [
                  "Name"
                ],
                "queryable": false,
                "searchable": false,
                "updateable": false
              }
            },
            //...truncated for display
            {
              "objectInfo": {
                "ApiName": "WorkOrderChangeEvent",
                "createable": false,
                "custom": false,
                "defaultRecordTypeId": null,
                "deletable": false,
                "feedEnabled": false,
                "keyPrefix": "1CE",
                "label": "Work Order Change Event",
                "labelPlural": "Work Order Change Event",
                "layoutable": false,
                "mruEnabled": false,
                "nameFields": [],
                "queryable": false,
                "searchable": false,
                "updateable": false
              }
            }
          ]
        }
      ]
    }
  },
  "errors": []
}
```

## Query Child Relationships for Account and Case

This example returns the child relationships for accounts and cases. It also runs an `objectInfo` subquery to fetch the `queryable` field on `childRelationships`.

```sfdocs-code {"lang":"graphql", "title": "Query Account and Case Child Relationships", "src": "" }
{
  uiapi {
    objectInfos(apiNames: ["Account", "Case"]) {
      ApiName
      childRelationships {
        childObjectApiName
        relationshipName
        objectInfo {
          ApiName
          queryable
        }
      }
    }
  }
}
```

The previous query returns this response.

```sfdocs-code {"lang":"json", "title": "Response for Account and Case Child Relationships Query", "src": "" }
{
  "data": {
    "uiapi": {
      "objectInfos": [
        {
          "ApiName": "Account",
          "childRelationships": [
            {
              "childObjectApiName": "Account",
              "relationshipName": "ChildAccounts",
              "objectInfo": {
                "ApiName": "Account",
                "queryable": true
              }
            },
            //...truncated for display
          ]
        }
      ]
    }
  }
}
```

## See Also

[Get Object Metadata](/docs/platform/graphql/guide/query-objectinfo.md)
