I am using wp-graphql-woocommerce with wp-graphql and wp-graphiql
here is my query query MyQuery {
products(first: 20) {
nodes {
productId
slug
name
price
}
}
}
it gives me an error Cannot query field "price" on type "Product".
@mehidi258 the schema design was changed drastically in v0.3.0, if you are using WPGraphiQL, I recommend using the Explorer panel to view and get a general idea of what the schema shape
I searched for price in wpgraphiql explorer but did not find. Can somebody please let me know how I can find price in products query
@ganeshpprasad Here's an example query. Prices fields only exist on the SimpleProduct and VariableProduct type.
query ($id: ID!, $idType: ProductIdTypeEnum) {
product(id: $id, idType: $idType) {
id
productId
name
... on SimpleProduct {
price
regularPrice
salePrice
dateOnSaleFrom
dateOnSaleTo
}
... on VariableProduct {
price
regularPrice
salePrice
dateOnSaleFrom
dateOnSaleTo
}
}
}
Most helpful comment
@ganeshpprasad Here's an example query. Prices fields only exist on the
SimpleProductandVariableProducttype.