Querying Products
Inside this guide:
Introduction
Querying for a Product
Next steps
Introduction
The coreProduct query allows you to retrieve the latest state of information Zencargo holds about a Product.
During these guides, we'll use a single sample Product to explain the query. If you want to follow along, it's a good idea to create a Product using the CreateCoreProduct outlined in the Creating a Product as we'll be using the same references in this guide. As a reminder, we send Zencargo a data structure that looks like this:
{
"input": {
"accountId": YOUR_ACCOUNT_UUID,
"name": "Blue T-Shirts",
"skuCode": "10000",
"barcode": "J48fFJ3811",
"categoryId": CATEGORY_UUID,
"dimensions": {
"width": 5,
"height": 10,
"length": 20,
"unit": "CM"
},
"weight": {
"unit": "G",
"value": 100
},
"unitsPerCarton": 5,
"characteristics": {
"hot": false,
"hazardous": false,
"specialHandling": false,
"refrigerated": false,
"stackable": true,
"garmentsOnHangers": false,
"healthCertificate": false,
"riskLevel": "LOW"
},
"attributes": {
"attributeId": ATTRIBUTE_UUID,
"value": "Blue"
},
"tariffCodes": {
"tariffRegionCode": "GB",
"tariffCode": "12345678"
},
"sellCostPrices": {
"sellCostPrice": {
"value": 5,
"currency": "GBP"
},
"mainPrice": true
},
"buyCostPrices": {
"buyCostPrice": {
"value": 5,
"currency": "GBP"
},
"manufacturerId": SUPPLIER_UUID
"mainPrice": true
}
}
}
Refer back to the CreateCoreProduct guide or the Concepts guide to learn more about the product data model.
Now let's explore a few use cases for querying product data.
Querying for a product
Constructing the mutation and input
For now we'll focus on querying a single Product using the id of the product.
We'll be using the API Console to save time having to authenticate. Copy and paste this into your API console query section to get started. Reminder that fields can be removed from the query if you don't want the API to return them.
POST /graphql
Query
query ($id: String!) {
coreProduct(id: $id) {
id
name
skuCode
barcode
category {
id
name
}
dimensions {
width
height
length
unit
}
weight {
value
unit
}
unitsPerCarton
cbmPerUnit
characteristics {
hot
hazardous
specialHandling
refrigerated
stackable
garmentsOnHangers
healthCertificate
riskLevel
}
attributes {
attribute {
id
name
type
}
value
}
tariffCodes {
tariffCode
tariffRegionCode
}
sellCostPrices {
sellCostPrice {
value
currency
}
mainPrice
}
buyCostPrices {
buyCostPrice {
value
currency
}
manufacturer {
id
}
mainPrice
}
status
}
}
Defining the variables
Copy and paste the block below into the query variables section of the API console and provide substitute the PRODUCT_ID with the product id you want to query.
Variables
{
"id": PRODUCT_ID
}
Now press Execute Query (the play button) to send the request.
You should get back this response containing all the requested product data of the id you provided.
NOTE: The various ids e.g. product id and category id will not match what you get back in the actual response.
JSON Response
{
"data": {
"coreProduct": {
"id": "cfeeb6ee-91c4-46b1-9411-71185d359324",
"name": "Blue T-Shirts",
"skuCode": "10000",
"barcode": "J48fFJ3811",
"category": {
"id": "b426b1d7-6210-4cd1-ac65-b3dc184c473b",
"name": "Clothes"
},
"dimensions": {
"width": 5,
"height": 10,
"length": 20,
"unit": "CM"
},
"weight": {
"unit": "G",
"value": 100
},
"unitsPerCarton": 5,
"cbmPerUnit": 100,
"characteristics": {
"hot": false,
"hazardous": false,
"specialHandling": false,
"refrigerated": false,
"stackable": true,
"garmentsOnHangers": false,
"healthCertificate": false,
"riskLevel": "LOW"
},
"attributes": [
{
"attribute": {
"id": "b6e596dd-203b-4867-a553-b782d5b0ea10",
"name": "Colour",
"type": "TEXT"
},
"value": "Blue"
}
],
"tariffCodes": [
{
"tariffRegionCode": "GB",
"tariffCode": "12345678"
}
],
"sellCostPrices": [
{
"sellCostPrice": {
"value": 5,
"currency": "GBP"
},
"mainPrice": true
}
],
"buyCostPrices": [
{
"buyCostPrice": {
"value": 5,
"currency": "GBP"
},
"manufacturer": {
"id": "b426b1d7-6210-4cd1-ac65-b3dc184c473b"
},
"mainPrice": true
}
],
"status": "ACTIVE"
}
}
}
Next Steps
- Create Product - Learn how to create a product
- Query Product - Learn how to query a product
- Update Product - Learn how to update a product
- Archive Product - Learn how to archive a product
- Unarchive Product - Learn how to unarchive a product
- Making your first call - If you're not sure how GraphQL works, start here.