Next.js Discord

Discord Forum

GraphQL issue

Unanswered
Atlantic cod posted this in #help-forum
Open in Discord
Atlantic codOP
Hi everyone,
I used that GraphQL query :

query ProductQuery(
    $category: String
    $minPrice: GraphQLStringOrFloat
    $maxPrice: GraphQLStringOrFloat
    $condition: String
    $materials: [String]
    $colors : [String]
) {
    Products(
        filter: {
            status: { _eq: "published" }
            availability: { _eq: "available" }
            condition: { _eq: $condition }
            price: { _between: [$minPrice, $maxPrice] }
            materials: { Materials_id: { name: { _in: $materials } } }
            colors: { Colors_id: { name: { _in: $colors } } }
        }
    ) {
        id
        name
        price
        slug
        thumbnail {
            id
            title
        }
        category(filter: { slug: { _eq: $category } }) {
            name
        }
    }
}


However, when i don't set any variables but category or set them null, i have no result as if variables were set. It's for them to be optional. If I remove those filters (but category) i have my results.
What is it due to ?

0 Replies