swellstores / swell-js

JS library for building storefronts and checkouts with Swell ecommerce.
https://swell.is
MIT License
139 stars 29 forks source link

type issue in products.list productQuery type #95

Open vettloffah opened 1 year ago

vettloffah commented 1 year ago

This is shown as a type error, however it is a valid API call:

// returns matching product results
const productResponse = await swell.products.list({
    id: { $in: productIds } // productIds is an array of IDs
})
image

And trying to do this same thing with the "where" flag actually doesn't properly return any products.

// this doesn't work even though it seems like it should (returns no results)
const productResponse = await swell.products.list({
    where: { id: { $in: productIds } }
})
awwit commented 1 year ago

@vettloffah I see that you are facing a type mismatch. We have not yet fully developed the type system, as you have already noticed.

Try wrapping your query condition in where:

const productResponse = await swell.products.list({
  where: {
    id: { $in: productIds } // productIds is an array of IDs
  }
})
vettloffah commented 1 year ago

Hi @awwit as I said in the original post here, the "where" flag returns no results, even though it should. That is why I created this issue.

awwit commented 1 year ago

Hi @vettloffah I checked that the where statement works fine for products.list. But only active products are returned, you may be trying to request inactive ones.

It looks like there is no way to query inactive products via products.list.