---
title: EntityQuery
framework: appintents
role: symbol
role_heading: Protocol
path: appintents/entityquery
---

# EntityQuery

An interface for locating app entity instances by identifier.

## Declaration

```swift
protocol EntityQuery : DynamicOptionsProvider, PersistentlyIdentifiable, Sendable
```

## Mentioned in

Defining app entities for your custom data types

## Overview

Overview An entity query defines how Apple Intelligence, Siri, and the Shortcuts app retrieve instances of a specific AppEntity type, and implements the lookup logic. To let Siri and Shortcuts retrieve AppEntity instances, create a type that conforms to EntityQuery. Resolve entities by identifier In some scenarios, Apple Intelligence already knows exactly which entity the person is referring to, and needs to retrieve the actual entity instance given its unique identifier. To support this retrieval method, implement entities(for:), which, given an array of AppEntity identifiers, returns corresponding entity instances. In your entities(for:) implementation, first look up whether the instance already exists in memory. If the instance doesn’t exist, make asynchronous calls — for example, retrieving from disk or a backend service. If the entity for a provided identifier is no longer available, omit it from the returned array. struct MyPhotoQuery: EntityQuery {     func entities(for identifiers: [UUID]) async throws -> [MyPhoto] {         myPhotoStore.filter { identifiers.contains($0.id) }     } }

## Topics

### Creating a query

- [init()](appintents/entityquery/init().md)

### Searching for entities

- [entities(for:)](appintents/entityquery/entities(for:).md)
- [Entity](appintents/entityquery/entity.md)

### Suggesting entities

- [suggestedEntities()](appintents/entityquery/suggestedentities().md)

### Associated Types

- [Result](appintents/entityquery/result.md)

### Instance Methods

- [displayRepresentations(for:requestedComponents:)](appintents/entityquery/displayrepresentations(for:requestedcomponents:).md)

### Type Aliases

- [EntityQuery.ExecutionTargets](appintents/entityquery/executiontargets.md)

### Type Properties

- [allowedExecutionTargets](appintents/entityquery/allowedexecutiontargets.md)

## Relationships

### Inherits From

- [DynamicOptionsProvider](appintents/dynamicoptionsprovider.md)
- [PersistentlyIdentifiable](appintents/persistentlyidentifiable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

### Inherited By

- [EntityPropertyQuery](appintents/entitypropertyquery.md)
- [EntityStringQuery](appintents/entitystringquery.md)
- [EnumerableEntityQuery](appintents/enumerableentityquery.md)
- [IndexedEntityQuery](appintents/indexedentityquery.md)
- [UniqueAppEntityQuery](appintents/uniqueappentityquery.md)

### Conforming Types

- [UniqueAppEntityProvider](appintents/uniqueappentityprovider.md)

## See Also

### Identifier-based queries

- [IndexedEntityQuery](appintents/indexedentityquery.md)
- [EnumerableEntityQuery](appintents/enumerableentityquery.md)
