Created
April 9, 2020 20:46
-
-
Save xavierzwirtz/fd79f8e9c73ffe17ba19328993b2999e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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