Created
July 31, 2017 18:13
-
-
Save nameofname/7d9461a28e057aa5dd30e7d11fbcfe4f to your computer and use it in GitHub Desktop.
Filters and Facets
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
// sample graphQl Query | |
// for our use case, we can ignore facets | |
/** | |
filters{ | |
name | |
values{ | |
urlLabel | |
displayName | |
count | |
} | |
} | |
facets{ | |
origin{ | |
name | |
label | |
code | |
serviceId | |
code | |
properties{ | |
displayName | |
} | |
} | |
} | |
*/ | |
// The below exapmles illustrate how facets are mapped to filters | |
// Many of the fields on a facet are not used, however we may want to use them in the future | |
// for example, properties.displayName may be better than name in some cases. | |
const facets = { | |
"ONE": [ // name | |
{ | |
"name": "ONE-1", // displayName | |
"label": "one-1", // urlLabel | |
"count": 10, // count | |
"code": null, | |
"serviceId": "123", | |
"uid": "one-1", | |
"properties": { | |
"displayName": "ONE-1x" | |
} | |
}, { | |
"name": "ONE-1", | |
"label": "one-1", | |
"count": 20, | |
"code": null, | |
"serviceId": "456", | |
"uid": "one-1", | |
"properties": { | |
"displayName": "ONE-1x" | |
} | |
} | |
], | |
"TWO": [ | |
{ | |
"name": "TWO-1", | |
"label": "two-1", | |
"count": 30, | |
"code": null, | |
"serviceId": "789", | |
"uid": "two-1", | |
"properties": { | |
"displayName": "TWO-1x" | |
} | |
}, { | |
/** ... */ | |
}, { | |
/** ... */ | |
} | |
] | |
}; | |
// Note* 'rank' is only present for applied filters | |
const filters = [{ | |
"name": "ONE", | |
"rank": 1, | |
"values": [ | |
{ | |
"displayName": "ONE-1", | |
"urlLabel": "one-1", | |
"count": 123 | |
} | |
]}, { | |
"name": "TWO", | |
"rank": 2, | |
"values": [ | |
{ | |
"displayName": "TWO-2", | |
"urlLabel": "two-2", | |
"count": 456 | |
} | |
] | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment