Documentation Index
Fetch the complete documentation index at: https://mintlify.com/directus/directus/llms.txt
Use this file to discover all available pages before exploring further.
Basic Queries
GraphQL queries in Directus are automatically generated based on your collections. For each collection, several query types are available.Query a Collection
Retrieve multiple items from a collection:Query by ID
Retrieve a single item by its primary key:Query System Collections
Use the/graphql/system endpoint to query system collections:
System collection names in the
/graphql/system endpoint don’t include the directus_ prefix.Filtering
Directus provides powerful filtering capabilities through GraphQL query arguments.Basic Filters
Filter Operators
Directus supports a comprehensive set of filter operators:| Operator | Description | Example |
|---|---|---|
_eq | Equal to | status: { _eq: "published" } |
_neq | Not equal to | status: { _neq: "draft" } |
_lt | Less than | views: { _lt: 100 } |
_lte | Less than or equal | views: { _lte: 100 } |
_gt | Greater than | views: { _gt: 1000 } |
_gte | Greater than or equal | views: { _gte: 1000 } |
_in | In array | status: { _in: ["published", "featured"] } |
_nin | Not in array | status: { _nin: ["draft", "archived"] } |
_null | Is null | deleted_at: { _null: true } |
_nnull | Is not null | published_at: { _nnull: true } |
_contains | Contains substring | title: { _contains: "GraphQL" } |
_ncontains | Doesn’t contain | title: { _ncontains: "draft" } |
_icontains | Contains (case-insensitive) | title: { _icontains: "graphql" } |
_starts_with | Starts with | title: { _starts_with: "How to" } |
_nstarts_with | Doesn’t start with | title: { _nstarts_with: "Draft:" } |
_istarts_with | Starts with (case-insensitive) | title: { _istarts_with: "how" } |
_ends_with | Ends with | title: { _ends_with: "Tutorial" } |
_nends_with | Doesn’t end with | title: { _nends_with: "[WIP]" } |
_iends_with | Ends with (case-insensitive) | title: { _iends_with: "tutorial" } |
_between | Between two values | views: { _between: [100, 1000] } |
_nbetween | Not between | views: { _nbetween: [0, 10] } |
Logical Operators
Combine multiple filters with logical operators:_and: All conditions must be true_or: At least one condition must be true
Nested Filters
Filter on related items:Sorting
Sort results using thesort argument:
- Prefix with
-for descending order - No prefix for ascending order
- Multiple sort fields are evaluated in order
Pagination
Control how many items are returned:Limit and Offset
Page-Based Pagination
Searching
Perform full-text search across multiple fields:The
search parameter performs a case-insensitive search across all string fields in the collection.Relationships
Directus automatically resolves relationships in GraphQL.Many-to-One (M2O)
One-to-Many (O2M)
Many-to-Many (M2M)
Filtering Related Items
Apply filters to related items:Aggregation
Query aggregated data using the_aggregated suffix:
Grouping
Group aggregations by field values:Available Aggregate Functions
count: Count of itemsavg: Average value (numeric fields)sum: Sum of values (numeric fields)min: Minimum valuemax: Maximum valueavgDistinct: Average of distinct valuessumDistinct: Sum of distinct valuescountDistinct: Count of distinct values
Versioning
Query content versions using the_by_version suffix:
The
_by_version queries are only available on the /graphql endpoint for item collections, not on /graphql/system.Deep Filtering
Filter parent items based on related item properties:Using Variables
Make queries reusable with variables:Fragments
Define reusable field selections:Aliases
Query the same collection multiple times with different arguments:Singleton Collections
For singleton collections, query without the_by_id suffix:
Example: Complex Query
Here’s a comprehensive example combining multiple features:Next Steps
GraphQL Mutations
Learn how to create, update, and delete data
GraphQL Subscriptions
Get real-time updates with subscriptions