---
title: "Query(_:animation:)"
framework: swiftdata
role: symbol
role_heading: Macro
path: "swiftdata/query(_:animation:)"
---

# Query(_:animation:)

Fetches only the subset of the attached model type that satisfy the provided fetch descriptor’s criteria.

## Declaration

```swift
@attached(accessor) @attached(peer, names: prefixed(`_`)) macro Query<Element>(_ descriptor: FetchDescriptor<Element>, animation: Animation) where Element : PersistentModel
```

## Parameters

- `descriptor`: The criteria, sort order, and any additional configuration to use when performing the fetch.
- `animation`: The animation to use when updates to the fetched models trigger user interface changes.

## See Also

### Descriptor-based queries

- [Query(_:transaction:)](swiftdata/query(_:transaction:).md)
