Interfaces & Types
These are the GraphQL interfaces and types Wishlist adds. The Queries page shows them in use.
Lists
The ListInterface Interface
The interface implemented by every list. Lists use a single type, List, which also holds the custom fields from your list types’ List Fields layouts. Request those inside a ... on List fragment, as shown in Querying Custom Fields.
As well as the fields below, the interface includes Craft’s standard element fields, such as id, uid, title, status, enabled, siteId, dateCreated and dateUpdated. A list’s title is its own title, which starts as its list type’s name.
{
wishlists(limit: 1) {
id
title
typeId
userId
reference
default
items(limit: 5) {
title
}
}
}The ID of the list’s list type.
The ID of the user who owns the list, or null for a guest’s list.
The list’s reference, which identifies it in shared list links.
Whether the list is its owner’s default list.
The items in the list, each as an Item type. It accepts the same arguments as the wishlistItems query, so you can sort, limit or filter a list’s items. The results are always limited to this list, whatever listId you pass.
{
wishlists(userId: 1) {
title
items(orderBy: "dateCreated DESC", limit: 3) {
title
element {
id
}
}
}
}Items
The ItemInterface Interface
The interface implemented by every item. Items use a single type, Item, which also holds the custom fields from your list types’ Item Fields layouts. Request those inside a ... on Item fragment.
As well as the fields below, the interface includes Craft’s standard element fields, such as id, uid, status, enabled, siteId, dateCreated and dateUpdated.
The title, elementId, elementClass and element fields describe the element the item links to. They return null when the schema can’t read that element, as Linked Element Permissions explains, so check for null before using them.
{
wishlistItems(listId: 4562) {
id
listId
title
elementId
elementClass
element {
title
url
}
}
}The title of the element the item links to.
The ID of the list the item belongs to.
The ID of the element the item links to.
The class of the element the item links to, such as craft\elements\Entry.
The element the item links to. Use a fragment for its type to request that type’s fields, such as a product’s variants or an entry’s custom fields.
{
wishlistItems(listId: 4562) {
element {
title
url
... on blog_Entry {
summary
}
}
}
}