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 catalogue.

In order to perform these operations, ensure that you have the proper authentication (if necessary) and user permissions.

Common Fields

Most of the query fields are identical across all items (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 catalogue 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 type for the plants folder in the demo tenant.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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, creation data, etc.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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 name, language, and path of a particular item.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Children

Folders usually have more items inside of them. The query below fetches all the items within the plants folder in the demo tenant.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Parent

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

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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 the date it was published. The following query asks for the aforementioned fields for a document.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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:

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Subtree

The subtree field works similarly 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:

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Components

A collection of components is what makes up a shape in Crystallize. This includes single line component, rich text, videos, file, etc. The following query asks for all the components present on the path specified. For simplicity's sake, we’re only retrieving rich text and image component information.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Component

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

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Topics

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

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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:

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Variants

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

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

stockLocations

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

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 (i.e. virtual products).

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...
People showing thumbs up

Need further help?

Join and ask our
slack community.

Join our slack community