Skip to main content
More in Learn

Query Fields

At its core, GraphQL queries simply ask for certain fields on objects. This section covers the query fields associated with the items present in the catalog.

Common Fields

Most of the query fields are identical across all the items, i.e., product, document, or folder. However, some fields are specific only to product items. Let's take a look at the common fields now!

ID, Name and Type

  • id: Every item in the catalog has its own unique id which can be queried using this field.
  • name: Refers to the name you have given to an item.
  • type: Returns the type of an item i.e whether it's a document, a folder, or a product.

Here's a query that asks for the id, name, and path for the plant’s folder in the demo tenant.

Shape

In Crystallize, you can define shapes for your items to have a more semantic structure. The shape field includes information such as the shape name, the identifier, the creation data, etc.

Language and Path

Any item, be it a product, a document, or a folder can be translated into multiple languages. The following query asks for the language and the path of a particular item.

Children

Folders usually have more items inside them. This item can belong to any of the shapes - product, document, and folder. The query below fetches all the items within the plants folder in the demo tenant.

Parent

Similar to how the child items are fetched, you can fetch the parent item as well. The example query below fetches the parent item of the plant’s folder.

Get Date and Time

Using the Catalogue API, you can ask for the following fields for any item - the date the item was created, the date it was uploaded, and lastly, the date it was published. The following query asks for the aforementioned fields for a document.

Relating Items

One of the components provided in the catalog is the Item Relation component. Through this component, you can link related items to a particular item. This field can be queried as follows:

Subtree

The subtree field works similar to how the children field works. However, when you want to slice items or when you want to add pagination, this is the field you would use. This field is discussed in more detail in the pagination section. Let's say you want to fetch only the top 3 items within a folder, this is how you can do it:

Components

A collection of components is what makes up a shape in Crystallize. This includes - single line component, rich text, switch component, images, videos, etc. The following query asks for all the components present on the path specified. For simplicity's sake, we are only asking for the content if it's a rich text component or if it's an image one.

Component

In case, you only want to grab a single component, you can ask for the component field. The component field requires the id of the component you would like to fetch. The query below fetches the rich text component with the id of brief.

Topics

Any of the items defined in Crystallize can have multiple topics attached to them. To fetch all the topics associated with a product, a document, or a folder, you can do the following:

Fields Specific to Product Items

As mentioned above, there are some fields that are specific to products only. This includes - vatType, isVirtual, isSubscriptionOnly, variants, and defaultVariants. Let's take a look at each of these in more detail.

Note: Keep in mind that since these fields are specific to the product, you will need to use the product type in the query.

vatType

This field fetches the vat type of a product and can be queried as follows:

Variants

In Crystallize, you can add any number of variants to a product. These variants can then be fetched as follows:

Additionally, the variant field allows you to fetch data including images, price, SKU, name, subscriptionPlans, attributes, stock, etc.

Default Variant

In case you only want to fetch the default variant, you can use this field instead. It simply fetches the default variant and its related information such as images, price, SKU, name, subscriptionPlans, attributes, stock, etc.

stockLocations

This is the property that will return the stock for each location. Stock locations are defined under settings.

Each variant will have its own set of values for the different locations. The locations can also have unlimited stock when no minimum value is defined, and this is good for products that don't have stock.

People showing thumbs up

Need further assistance?

Ask the Crystallize team or other enthusiasts in our slack community.

Join our slack community