Queries

Available queries

Variant - Returns a single variant based on the id provided

query {
  Variant (id: 100012) {
    id
    label
    on_hand
    available
    incoming
    valuation
  }
}

Variants - Returns a list of variants based on the filter define

query {
  Variants {
    data {
    	id
    	label
        sku
    }
  }
}


Available fields

id
Unique identifier of the variant
label
Name of the variant
sku
Sku of the variant
suppliers
Suppliers for the variant
barcode
Barcode of the variant
type
Type of the variant (normal, kit, assembly, packaging)
track_inventory
If true, the inventory is tracked (changed based on documents, adjustments, ...)
initial_cost
Initial cost of the variant
unit_cost
Current cost of the variant
last_cost
Last cost used for the variant
purchase_price_amount
Purchase price of the variant
purchase_price_currency
Currency of the purchase price (GBP, USD, ...)
weight_amount
Weight of the variant
weight_unit
Unit for the variant's weight (kg, g, lb, oz)
active
If false, the product is inactive, and can not be added in documents
created_at
Creation date of the variant
updated_at
Date of the latest modification of the variant
attribute1
Variant attribute for the first option of the product (ex: "red" for Color option)
attribute2
Variant attribute for the second option of the product (ex: "XL" for Size option)
attribute3
Variant attribute for the third option of the product (ex: "iron" for Material option)
product
Product of the variant
shipped_this_month
Quantity of this variant shipped this month
stock_levels
  • Array of StockLevel
Stock levels of the variant on the locations
on_hand
On hand quantity in stocks for the variant
available
Available quantity of the variant
incoming
Incoming quantity for the variant (quantity purchased but not delivered)
reserved
Reserved quantity for the variant (quantity sold but not delivered)
valuation
Valuation of the variant (value of the on hand quantity)
components
List of the components of the variant for a kit or an assembly
component_of
List of the kit or assembly that have this variant as component
packagings
List of the packagings of this variant
has_batch_numbers
If true, the variant has batches
batch_number_stock_levels
  • Array of [BatchNumberStockLevel]
Stock levels by location for the batches of the variant
batch_numbers
  • Array of [BatchNumber]
Batch numbers of the variant


Filters

You can create filters based on following fields

label
Example:{ "column" : "LABEL", "operator" : "LIKE", "value" : "%011%" }
sku
Example: { "column" : "SKU", "operator" : "LIKE", "value" : "DE889%" }
barcode
Example: { "column" : "BARCODE", "operator" : "LIKE", "value" : "111212887%" }
type
Example: { column": "TYPE", "operator": "EQ", "value": "kit"
on_hand
Example:{ "column": "ON_HAND", "operator": "LT", "value": 5 }
available
Example:{ "column": "AVAILABLE", "operator": "LT", "value": 10 }
incoming
Example:{ "column": "INCOMING", "operator": "GT", "value": 100 }
reserved
Example:{ "column": "RESERVED", "operator": "GT", "value": 5 }
track_inventory
Example :{ column": "TRACK_INVENTORY", "operator": "EQ", "value": true }
location_id
Example: { "column": "LOCATION_ID", "operator": "EQ", "value": 1000012 }
bin_location
Example: { "column": "BIN_LOCATION", "operator": "EQ", "value": "loc12" }
supplier_id
Example: { column": "SUPPLIER_ID", "operator": "EQ", "value": 212562 }
supplier_sku
Example: { "column": "SUPPLIER_SKU", "operator": "EQ", "value": "12B5621" }
product_id
Example: { "column": "PRODUCT_ID", "operator": "EQ", "value": 310291 }
shipped_this_month
Example: { "column": "SHIPPED_THIS_MONTH", "operator": "GT", "value": 200 }

Sorting

You can sort data based on following fields : id, label, sku, product_id, barcode, track_inventory, initial_cost, unit_cost, purchase_price_amount, purchase_price_currency, weight_amount, weight_unit, active, created_at, updated_at, shipped_this_month, on_hand, available, incoming, reserved

query Variants(
  $orderBy: [QueryVariantsOrderByOrderByClause!], 
  $first: Int = 50, 
  $page: Int
) {
  Variants(
    orderBy: $orderBy
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
    }
    data {
      id
      sku
      type
      label
      on_hand
      track_inventory
    }
  }
}
{
  "orderBy": [
    {
      "column": "UNIT_COST",
      "order": "DESC"
    },
  ],
  "first": 50,
  "page": 1,
}

Example of a query

query Variants(
  $where: QueryVariantsWhereWhereConditions, 
  $first: Int = 50, 
  $page: Int
) {
  Variants(
    where: $where
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
      count
      currentPage
      perPage
    }
    data {
      id
      type
      product {
        id
      }
      label
      sku
      on_hand
      available
      reserved
      incoming
    }
  }
}
{
  "first": 50,
  "page": 1,
  "where": {
    "AND": [
      {
        "AND": [
          {
            "column": "TRACK_INVENTORY",
            "operator": "EQ",
            "value": true
          },
          {
            "column": "ACTIVE",
            "operator": "EQ",
            "value": true
          },
          {
            "column": "TYPE",
            "operator": "NEQ",
            "value": "packaging"
          }
        ]
      },
      {
        "AND": [
          {
            "column": "LABEL",
            "operator": "LIKE",
            "value": "%asics coat%"
          },
          {
            "column": "SKU",
            "operator": "LIKE",
            "value": "%j%"
          }
        ]
      }
    ]
  }
}

Example of data returned

{
  "data": {
    "Variants": {
      "paginatorInfo": {
        "total": 2,
        "count": 2,
        "currentPage": 1,
        "perPage": 50
      },
      "data": [
        {
          "id": 100053,
          "type": "normal",
          "product": {
            "id": 100014
          },
          "label": "Impressive Asics Coat - Black - L",
          "sku": "wk831kx8Jt",
          "on_hand": null,
          "available": null,
          "reserved": null,
          "incoming": null
        },
        {
          "id": 100054,
          "type": "normal",
          "product": {
            "id": 100014
          },
          "label": "Impressive Asics Coat - White - XL",
          "sku": "iyy32NjImQ",
          "on_hand": null,
          "available": null,
          "reserved": null,
          "incoming": null
        }
      ]
    }
  }
}