Wp-graphql-woocommerce: Price not showing on products query

Created on 21 Nov 2019  路  3Comments  路  Source: wp-graphql/wp-graphql-woocommerce

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".

Most helpful comment

@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
        }
    }
}

All 3 comments

@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
        }
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohaimenmahi picture mohaimenmahi  路  5Comments

ricokahler picture ricokahler  路  5Comments

huniqcast picture huniqcast  路  4Comments

dpacmittal picture dpacmittal  路  5Comments

huniqcast picture huniqcast  路  3Comments