Tento Product Query

List

Tento represents Shopify Products query

If don’t provide partial fields selection Tento will return all possible fields for Product

const result = await client.metaobjects.products.list();
// result type
const result: {
  items: {
    id: string;
    createdAt: Date;
    updatedAt: Date;
    isGiftCard: boolean;
    category?: {
      fullName: string;
      id: string;
      isLeaf: boolean;
      isRoot: boolean;
      name: string;
      ancestorIds: number[];
      childrenIds: number[];
      isArchived: boolean;
      level: number;
      parentId?: number | undefined;
    } | undefined;
    ... 30 more ...;
    vendor: string;
    }[];
  pageInfo: {
    startCursor: string;
    endCursor: string;
    hasNextPage: boolean;
    hasPreviousPage: boolean;
  };
}

Partial fields select

fields parameter lets you include or omit fields you want to get from Shopify.

Tento performs partial selects on the query level, no additional data is transferred from the Shopify.

Get including only with just id, title:

const result = await client.metaobjects.products.list({
  fields: {
    id: true,
    title: true,
  },
});
// result type
const result: {
  items: {
    id: string;
    title: string;
  }[];
  pageInfo: {
    startCursor: string;
    endCursor: string;
    hasNextPage: boolean;
    hasPreviousPage: boolean;
  };
}


Get excluding id, handle, updatedAt, description:

const result = await client.products.list({
  fields: {
    id: false,
    handle: false,
    updatedAt: false,
    description: false,
  },
});
// result type
const result: {
  items: {
    createdAt: Date;
    isGiftCard: boolean;
    category: {
      fullName: string;
      id: string;
      isLeaf: boolean;
      isRoot: boolean;
      name: string;
      ancestorIds: number[];
      childrenIds: number[];
      isArchived: boolean;
      level: number;
      parentId?: number | undefined;
    } | undefined;
    ... 28 more ...;
    vendor: string;
  }[];
  pageInfo: {
    startCursor: string;
    endCursor: string;
    hasNextPage: boolean;
    hasPreviousPage: boolean;
  };
}


Exclude and Include fields in the same query:

When both true and false select options are present, all false options are ingored.

If you include the title field and exclude the id field, id exclusion will be redundant, all fields apart from title would be excluded anyways.

const result = await client.metaobjects.products.list({
  fields: {
    id: false,
    title: true,
  },
});
// result type
const result: {
  items: {
    title: string;
  }[];
  pageInfo: {
    startCursor: string;
    endCursor: string;
    hasNextPage: boolean;
    hasPreviousPage: boolean;
  };
}

Filters

Tento supports all pecific filters what Shopify has, see here.
Especially for products querying Tento supports all Shopify Products Query filters.

eq

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
   title: "product #1"
  },
});

not

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
   title: {
      $not: "product #1"
    }
  },
});

gt

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
    id: {
      $gt: "1"
    }
  },
});

gte

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
    id: {
      $gte: "1"
    }
  },
});

lt

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
    id: {
      $lt: "1"
    }
  },
});

lte

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
    id: {
      $lte: "1"
    }
  },
});

raw

const result = await client.products.list({
  query: {
   $raw: "id:1"
  },
});

and

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: [
      {
        id: '1'
      },
      {
        id: {
          $lte: "2",
        },
      },
    ],
});

or

Supported fields to filter

fieldsdefault, barcode, bundles, categoryId, combinedListingRole, createdAt, deliveryProfileId, giftCard, handle,
hasOnlyComposites, hasOnlyDefaultVariant, hasVariantWithComponents, id, inventoryTotal, isPriceReduced,
outOfStockSomewhere, price, productConfigurationOwner, productType, publishedStatus, publishedAt, sku, status,
tag, tagNot, title, updatedAt, vendor
const result = await client.products.list({
  query: {
    $or: [
      {
        id: "1",
      },
      {
        id: {
          $gt: "1",
        },
      },
    ],
  },
});

Pagination

Tento supports Shopify pagination

first

Supported pagination options

optiondefaultdescription
first50requested number of nodes for each page.
after-cursor to retrieve nodes after in the connection.
const result = await client.products.list({
  first: 10,
  after: "In0="
});

last

Supported pagination options

optiondefaultdescription
last-requested number of nodes for each page.
before-cursor to retrieve nodes after in the connection.
IMPORTANT

To provide last option you must specify before cursor to prevent exceptions.

const result = await client.products.list({
  last: 10,
  before: "In0="
});

Sort

Tento supports Shopify Products query sort keys Supported sort keys

keysid, created_at, inventory_total, product_type, published_at, relevance, title ,updated_at , vendor
const result = await client.products.list({
  sortKey: 'id'
});

You can control sort direction using reverse option. Default value is false.

const result = await client.products.list({
  sortKey: 'id',
  reverse: true,
});