GraphQL#

Wishlist supports accessing Item and List objects via GraphQL. Be sure to read about Craft's GraphQL support (opens new window).

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.

ArgumentTypeDescription
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.
archivedBooleanNarrows the query results to only elements that have been archived.
trashedBooleanNarrows 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.
siteIdStringDetermines which site(s) the elements should be queried in. Defaults to the current (requested) site.
uniqueBooleanDetermines whether only elements with unique IDs should be returned by the query.
enabledForSiteBooleanNarrows 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.
searchStringNarrows 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.
fixedOrderBooleanCauses the query results to be returned in the order specified by the id argument.
inReverseBooleanCauses 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.
offsetIntSets the offset for paginated results.
limitIntSets the limit for paginated results.
orderByStringSets the field the returned elements should be ordered by
typeIdStringNarrows the query results based on the list type ID.
userIdStringNarrows the query results based on the list’s owner.
sessionIdStringNarrows the query results based on the list’s session ID.
referenceStringNarrows the query results based on the list’s reference.
defaultBooleanNarrows the query results based on whether it is the default list.

The ListInterface interface#

This is the interface implemented by all lists.

FieldTypeDescription
idIDThe id of the entity
uidStringThe uid of the entity
_countIntReturn a number of related elements for a field.
titleStringThe element’s title.
slugStringThe element’s slug.
uriStringThe element’s URI.
enabledBooleanWhether the element is enabled or not.
archivedBooleanWhether the element is archived or not.
siteIdIntThe ID of the site the element is associated with.
searchScoreStringThe element’s search score, if the search parameter was used when querying for the element.
trashedBooleanWhether the element has been soft-deleted or not.
statusStringThe element's status.
dateCreatedDateTimeThe date the element was created.
dateUpdatedDateTimeThe 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.

ArgumentTypeDescription
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.
archivedBooleanNarrows the query results to only elements that have been archived.
trashedBooleanNarrows 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.
siteIdStringDetermines which site(s) the elements should be queried in. Defaults to the current (requested) site.
uniqueBooleanDetermines whether only elements with unique IDs should be returned by the query.
enabledForSiteBooleanNarrows 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.
searchStringNarrows 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.
fixedOrderBooleanCauses the query results to be returned in the order specified by the id argument.
inReverseBooleanCauses 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.
offsetIntSets the offset for paginated results.
limitIntSets the limit for paginated results.
orderByStringSets the field the returned elements should be ordered by
listIdStringNarrows the query results based on the list ID.
elementIdStringNarrows the query results based on the owner element ID.
elementClassStringNarrows the query results based on the owner element class.

The ItemInterface interface#

This is the interface implemented by all items.

FieldTypeDescription
idIDThe id of the entity
uidStringThe uid of the entity
_countIntReturn a number of related elements for a field.
titleStringThe element’s title.
slugStringThe element’s slug.
uriStringThe element’s URI.
enabledBooleanWhether the element is enabled or not.
archivedBooleanWhether the element is archived or not.
siteIdIntThe ID of the site the element is associated with.
searchScoreStringThe element’s search score, if the search parameter was used when querying for the element.
trashedBooleanWhether the element has been soft-deleted or not.
statusStringThe element's status.
dateCreatedDateTimeThe date the element was created.
dateUpdatedDateTimeThe date the element was last updated.

Previous ← Events