Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierzwirtz/fd79f8e9c73ffe17ba19328993b2999e to your computer and use it in GitHub Desktop.
Save xavierzwirtz/fd79f8e9c73ffe17ba19328993b2999e to your computer and use it in GitHub Desktop.
// this bit is pseudo code to describe the filter expression
type ComparisonMethod =
| Contains
| Equals
type FieldValue =
{ Name : string
, Value : string
, ComparisonMethod
}
type WebCategoryItemFilterExpressionBody =
| FieldValue of FieldValue
type WebCategoryItemFilterExpression =
| Single of WebCategoryItemFilterExpressionBody
| Or of list<WebCategoryItemFilterExpressionBody>
| And of list<WebCategoryItemFilterExpressionBody>
// actual graphql expression
query Q(
$webCategoryId: Guid!,
$itemFilter: WebCategoryItemFilterExpression,
) {
webCategory(id: $id) {
filteredItems(filter: $itemFilter) {
description
itemNo
}
}
}
// where filter could be:
/*
Or([
(Or([
(FieldValue { Name = "field1"
, Value = "foo"
, ComparisonMethod = Equals })
(FieldValue { Name = "field2"
, Value = "foo"
, ComparisonMethod = Equals })
])),
(And([
(FieldValue { Name = "field2"
, Value = "foo"
, ComparisonMethod = Equals })
(FieldValue { Name = "field3"
, Value = "foo"
, ComparisonMethod = Equals })
]))
(Single(FieldValue { Name = "field4"
, Value = "foo"
, ComparisonMethod = contains }))
])
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment