GraphQL
Wishlist supports accessing Item and List objects via GraphQL. Be sure to read about Craft's GraphQL support (opens new window).
Linked Element Permissions
The schema must permit both the wishlist list type and the linked element’s section, volume, product type or other supported scope. Site and lifecycle permissions also apply. When a linked element is unavailable to the schema, the wishlist item remains in an ordinary query, but its title, elementId, elementClass and element fields return null. Use the wishlist item’s own id and listId to show an unavailable-item placeholder.
Queries using title, search, elementId or elementClass, or sorting by linked-element metadata, return only items whose linked elements the schema can read. This restriction is applied before limit and offset, including for nested list items queries. These queries need additional permission checks over matching items, so prefer a specific listId when searching within one wishlist. Ordinary item ordering, such as orderBy: "id ASC", retains unavailable-item placeholders.
Lists
Example
{
wishlists (userId: 1) {
title
items {
title
}
}
}{
"data": {
"wishlists": [
{
"title": "Wishlist",
"items": [
{
"title": "Some Entry"
}
]
},
{
"title": "Favourites",
"items": []
}
]
}
}The wishlists Query
This query is used to query for lists.
| Argument | Type | Description |
|---|---|---|
id | [QueryArgument] | Narrows the query results based on the elements’ IDs. |
uid | [String] | Narrows the query results based on the elements’ UIDs. |
status | [String] | Narrows the query results based on the elements’ statuses. |
archived | Boolean | Narrows the query results to only elements that have been archived. |
trashed | Boolean | Narrows the query results to only elements that have been soft-deleted. |
site | [String] | Determines which site(s) the elements should be queried in. Defaults to the current (requested) site. |
siteId | String | Determines which site(s) the elements should be queried in. Defaults to the current (requested) site. |
unique | Boolean | Determines whether only elements with unique IDs should be returned by the query. |
enabledForSite | Boolean | Narrows the query results based on whether the elements are enabled in the site they’re being queried in, per the site argument. |
title | [String] | Narrows the query results based on the elements’ titles. |
slug | [String] | Narrows the query results based on the elements’ slugs. |
uri | [String] | Narrows the query results based on the elements’ URIs. |
search | String | Narrows the query results to only elements that match a search query. |
relatedTo | [Int] | Narrows the query results to elements that relate to any of the provided element IDs. This argument is ignored, if relatedToAll is also used. |
relatedToAll | [Int] | Narrows the query results to elements that relate to all the provided element IDs. Using this argument will cause relatedTo argument to be ignored. |
ref | [String] | Narrows the query results based on a reference string. |
fixedOrder | Boolean | Causes the query results to be returned in the order specified by the id argument. |
inReverse | Boolean | Causes the query results to be returned in reverse order. |
dateCreated | [String] | Narrows the query results based on the elements’ creation dates. |
dateUpdated | [String] | Narrows the query results based on the elements’ last-updated dates. |
offset | Int | Sets the offset for paginated results. |
limit | Int | Sets the limit for paginated results. |
orderBy | String | Sets the field the returned elements should be ordered by |
typeId | String | Narrows the query results based on the list type ID. |
userId | String | Narrows the query results based on the list’s owner. |
reference | String | Narrows the query results based on the list’s reference. |
default | Boolean | Narrows the query results based on whether it is the default list. |
The ListInterface Interface
This is the interface implemented by all lists.
| Field | Type | Description |
|---|---|---|
id | ID | The id of the entity |
uid | String | The uid of the entity |
_count | Int | Return a number of related elements for a field. |
title | String | The element’s title. |
slug | String | The element’s slug. |
uri | String | The element’s URI. |
enabled | Boolean | Whether the element is enabled or not. |
archived | Boolean | Whether the element is archived or not. |
siteId | Int | The ID of the site the element is associated with. |
searchScore | String | The element’s search score, if the search parameter was used when querying for the element. |
trashed | Boolean | Whether the element has been soft-deleted or not. |
status | String | The element's status. |
dateCreated | DateTime | The date the element was created. |
dateUpdated | DateTime | The date the element was last updated. |
items | [ItemInterface] | The lists’ items. Accepts the same arguments as the wishlistItems query. |
Items
Example
{
wishlistItems (listId: 4562, limit: 1) {
element {
id
title
}
}
}{
"data": {
"wishlistItems": [
{
"element": {
"id": "14931",
"title": "Some Entry"
}
},
]
}
}The wishlistItems Query
This query is used to query for items.
| Argument | Type | Description |
|---|---|---|
id | [QueryArgument] | Narrows the query results based on the elements’ IDs. |
uid | [String] | Narrows the query results based on the elements’ UIDs. |
status | [String] | Narrows the query results based on the elements’ statuses. |
archived | Boolean | Narrows the query results to only elements that have been archived. |
trashed | Boolean | Narrows the query results to only elements that have been soft-deleted. |
site | [String] | Determines which site(s) the elements should be queried in. Defaults to the current (requested) site. |
siteId | String | Determines which site(s) the elements should be queried in. Defaults to the current (requested) site. |
unique | Boolean | Determines whether only elements with unique IDs should be returned by the query. |
enabledForSite | Boolean | Narrows the query results based on whether the elements are enabled in the site they’re being queried in, per the site argument. |
title | [String] | Narrows the query results based on the elements’ titles. |
slug | [String] | Narrows the query results based on the elements’ slugs. |
uri | [String] | Narrows the query results based on the elements’ URIs. |
search | String | Narrows the query results to only elements that match a search query. |
relatedTo | [Int] | Narrows the query results to elements that relate to any of the provided element IDs. This argument is ignored, if relatedToAll is also used. |
relatedToAll | [Int] | Narrows the query results to elements that relate to all the provided element IDs. Using this argument will cause relatedTo argument to be ignored. |
ref | [String] | Narrows the query results based on a reference string. |
fixedOrder | Boolean | Causes the query results to be returned in the order specified by the id argument. |
inReverse | Boolean | Causes the query results to be returned in reverse order. |
dateCreated | [String] | Narrows the query results based on the elements’ creation dates. |
dateUpdated | [String] | Narrows the query results based on the elements’ last-updated dates. |
offset | Int | Sets the offset for paginated results. |
limit | Int | Sets the limit for paginated results. |
orderBy | String | Sets the field the returned elements should be ordered by |
listId | String | Narrows the query results based on the list ID. |
elementId | String | Narrows the query results based on the owner element ID. |
elementClass | String | Narrows the query results based on the owner element class. |
The ItemInterface Interface
This is the interface implemented by all items.
| Field | Type | Description |
|---|---|---|
id | ID | The id of the entity |
uid | String | The uid of the entity |
_count | Int | Return a number of related elements for a field. |
title | String | The element’s title. |
slug | String | The element’s slug. |
uri | String | The element’s URI. |
enabled | Boolean | Whether the element is enabled or not. |
archived | Boolean | Whether the element is archived or not. |
siteId | Int | The ID of the site the element is associated with. |
searchScore | String | The element’s search score, if the search parameter was used when querying for the element. |
trashed | Boolean | Whether the element has been soft-deleted or not. |
status | String | The element's status. |
dateCreated | DateTime | The date the element was created. |
dateUpdated | DateTime | The date the element was last updated. |