Skip to content

How to create conditional queries #328

Closed Answered by budde377
abhiche asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for reaching out @abhiche.

While I don't think the question is specific to this code-generator but a general GraphQL question, I believe the answer is: No.

The GraphQL language does not support any conditional expressions. Instead, what you can do is to expose the filter through a variable.

query getOrders($filter: FilterInputType) {
  orders(filter: $filter, sort: ["-date_created"]) {
    id
    order_no
    date_created
    channel
    payment_method
    shipping_name
    phone
    total_amount
    status
  }
}

This will allow you to conditionally generate any filter you need.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by budde377
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants