Introduction
In this lab we will be exploring how to add filters to your query.
Prerequisites
- Complete Getting Started
- Complete Exploring the Query
Lab Objective
- Understand the available filter criteria
- Understand criteria grouping
- Ability to identify available filter criteria
- Create a basic filter
- Create a grouped filter
Available Filters Types
- Strings - scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
- Comparisons
- equals - Returns data if the value equals the criteria
- notequals - Returns all other data than the values which equal the criteria
- contains - Returns data if the value contains a sub-string given for the criteria. (Can use RegEx)
- match - Returns data if the criteria matches a pattern. (Can use RegEx)
- Boolean - true/false
- Integer - scalar type represents non-fractional signed whole numeric values
- Comparisons
- equals - Returns data if the value equals the criteria
- notequals - Returns all other data than the values which equal the criteria
- gt - greater than
- gte - greater than or equal to
- lt - less than
- lte - less than or equal to
- Enumerations - scalar type represents a predefined list of values. Similar to a string, but does not accept quotes.
- Comparisons
- equals - Returns data if the value equals the criteria
- notequals - Returns all other data than the values which equal the criteria
Filter Grouping
While single filters can be useful, it is common to need more that one filter to return the data you are looking for. The grouping filters are "and", "or", and "not". They can be used by themselves to group one or more filters or in conjunction with each other to create more complex filters.
Adding our first filter
Click + Add new in the top bar of Altair
-
Copy the query from the "Exploring the Query" lab.
pageInfo { endCursor hasNextPage } intervalInfo { interval timezone } } }
-
Uncomment "filter:"
- Next to "filter:" add
- Send the request
- Open the Docs panel
- Navigate Query > task > filter > ChannelTypeExpression (do not click channelType as it will not show you the next level of information) > (next to equals) ChannelTypes
- Note that this is an enum filter type
- In the Docs panel, click the back button until you get back to TaskFilters
- Navigate to terminiationType
What type of filter is terminationType?
String
- Before we can add this filter to our query, we need to create an "and" group. Add the "and" group like this.
Below the channelType filter and still inside the and brackets, add a filter for terminationType to equal "normal".
- Send the request.
- You should only have records returned which were both from the telephony channelType and had a "normal" terminationType
-
What if you wanted to see all calls which did not terminate normally?
you could change "equals" to "notequals"OR you could place the filter in a "not" group filter
3. Change your filters to return calls which did not have a terminiationType of "normal" - What terminationTypes are returned?
⚠️ Note that the use of the "not" group filter will be evaluated differently based on placement.
-
This filter will evaluate as not channelType email AND not isActive false and will return every record that matches both criteria
-
This filter will evaluate as not channelType email AND not isActive false and return every record that does not match both criteria