Queries

Available queries

Product - Returns a single product based on the id provided

query {
  Product (id: 100012) {
    id
    label
    variants {
      id
      label
    }
  }
}

Products - Returns a list of products based on the filter define

query {
  Products {
    data {
      id
      label
      sku
    }
  }
}


Available fields

id
Unique identifier of the product
label
Name of the product
description
Description of the product
active
If true, the product is active and can be used in documents
created_at
Creation date of the product
updated_at
Date of the latest product modification
option1
First option of the product (ex: color)
option2
Second option of the product (ex: size)
option3
Third option of the product (ex: material)
variants
List of the variants of the product (based on attributes of options
suppliers
Suppliers for this product


Filters

You can create filters based on following fields

label
Example: { "column" : "LABEL", "operator" : "LIKE", "value" : "%011%" }
sku (of the variants)
Example: { "column" : "SKU", "operator" : "EQ", "value" : "135267U23" }
active
Example: { column": "ACTIVE", "operator": "EQ", "value": true
created_at
Example: { "column": "CREATED_AT", "operator": "LT", "value": "2024-01-11" }
updated_at
Example: { "column": "UPDATED_AT", "operator": "LT", "value": "2024-01-11" }
option1_id
Example: { "column": "OPTION1_ID", "operator": "EQ", "value": 102345 }
option2_id
Example: { "column": "OPTION2_ID", "operator": "EQ", "value": 102346 }
option3_id
Example: { "column": "OPTION3_ID", "operator": "EQ", "value": 102347 }

Sorting

You can sort data based on following fields : id, label, active, created_at, updated_at

query Products(
  $orderBy: [QueryProductsOrderByOrderByClause!],
  $first: Int = 50, 
  $page: Int
) {
  Products(
    orderBy: $orderBy
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
    }
    data {
      id
      label
    }
  }
}
{
  "orderBy": [
    {
      "column": "LABEL",
      "order": "ASC"
    }
  ],
  "first": 50,
  "page": 1
}

Example of a query

query Products(
  $where: QueryProductsWhereWhereConditions, 
  $first: Int = 50, 
  $page: Int
) {
  Products(
    where: $where
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
      count
      currentPage
      perPage
    }
    data {
      id
      label
      suppliers {
        paginatorInfo {
          total
        }
        data {
          id
          label
        }
      }
      active
      option1 {
        id
        label
      }
      variants {
        paginatorInfo {
          total
        }
        data {
          id
          sku
          type
          label
          on_hand
          track_inventory
        }
      }
    }
  }
}
{
  "first": 50,
  "page": 1,
  "where": {
    "AND": [
      {
        "AND": [
          {
            "column": "SKU",
            "operator": "LIKE",
            "value": "%QF%"
          }
        ]
      }
    ]
  }
}

Example of data returned

{
  "data": {
    "Products": {
      "paginatorInfo": {
        "total": 2,
        "count": 2,
        "currentPage": 1,
        "perPage": 50
      },
      "data": [
        {
          "id": 100141,
          "label": "Amazeballs Adidas Jacket",
          "suppliers": {
            "paginatorInfo": {
              "total": 0
            },
            "data": []
          },
          "active": true,
          "option1": null,
          "variants": {
            "paginatorInfo": {
              "total": 1
            },
            "data": [
              {
                "id": 100181,
                "sku": "ktQFtdxE7S",
                "type": "normal",
                "label": "Amazeballs Adidas Jacket",
                "on_hand": 100,
                "track_inventory": true
              }
            ]
          }
        },
        {
          "id": 100266,
          "label": "Imposing Lotto Pants",
          "suppliers": {
            "paginatorInfo": {
              "total": 0
            },
            "data": []
          },
          "active": true,
          "option1": null,
          "variants": {
            "paginatorInfo": {
              "total": 1
            },
            "data": [
              {
                "id": 100306,
                "sku": "nfhnCh3qfp",
                "type": "normal",
                "label": "Imposing Lotto Pants",
                "on_hand": null,
                "track_inventory": true
              }
            ]
          }
        }
      ]
    }
  }
}