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.
- 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.
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.
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:
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:
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.
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:
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.
This field fetches the VAT type of a product and can be queried as follows:
Additionally, the variant field allows you to fetch data including images, price, SKU, name, subscriptionPlans, attributes, stock, etc.
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).