Filters

GraphQL filters are a feature that allows you to retrieve data from your API based on specific criteria. With filters, you can selectively retrieve only the data that matches your desired criteria, reducing the amount of data returned and improving your application's performance. GraphQL filters are a powerful tool for creating more efficient and targeted queries. You can use filters in a variety of use cases, such as searching and filtering data or aggregating and analyzing large datasets. This document provides an overview of GraphQL filters and explains how to use them in your API queries.

Each entity in the Finite State API has a set of filters that can be used to get the information you are looking for, and reduce the amount of data returned.

The Finite State API has an extensive number of filters which are different for each type of entity. For example, the Product entity has a different set of filters than the Finding entity. The filters for each entity are defined in the GraphQL schema for that entity.

Common Filters

Scalar fields have a consistent set of filters no matter which type they belong to.

Commonly used Entity filters include:

DateTime

Filters for DateTime fields (such as createdAt) include:

FilterDescription
gtGreater than (after) the specified date
gteGreater than or equal to (after or equal to) the specified date
inIn the specified list of dates
ltLess than (before) the specified date
lteLess than or equal to (before or equal to) the specified date
notNot equal to the specified date
not_inNot in the specified list of dates

String

Filters for String fields (such as name) include:

FilterDescription
containsContains the specified value (case-sensitive)
ends_withEnds with the specified value (case-sensitive)
gtGreater than (after) the specified value (case-sensitive). Can be used for sorting.
gteGreater than or equal to (after or equal to) the specified value (case-sensitive). Can be used for sorting.
inIn the specified list of values (case-sensitive)
likeMatches against a pattern case-insensitively with the following placeholders: %: matches any sequence of characters, including the empty string; _ matches exactly one character; \ can be used to escape the placeholders (use \ for a literal backslash)
ltLess than (before) the specified value (case-sensitive). Can be used for sorting.
lteLess than or equal to (before or equal to) the specified value (case-sensitive). Can be used for sorting.
notNot equal to the specified value (case-sensitive)
not_containsDoes not contain the specified value (case-sensitive)
not_ends_withDoes not end with the specified value (case-sensitive)
not_inNot in the specified list of values (case-sensitive)
not_likeDoes not match against a pattern case-insensitively with the following placeholders: %: matches any sequence of characters, including the empty string; _ matches exactly one character; \ can be used to escape the placeholders (use \ for a literal backslash)
not_starts_withDoes not start with the specified value (case-sensitive)
starts_withStarts with the specified value (case-sensitive)

Filters on Fields

In addition, these filters can be combined with field names on an entity to apply the filter to the field.

For example, to filter the createdAt field on a Finding, you could use the following filters that are part of the FindingFilter type:

FilterDescription
createdAt_gtcreatedAt is greater than (after) the specified date
createdAt_gtecreatedAt is greater than or equal to (after or equal to) the specified date
createdAt_ltcreatedAt is less than (before) the specified date
createdAt_ltecreatedAt is less than or equal to (before or equal to) the specified date

Some filters available on name fields for ProductFilter:

FilterDescription
name_likeMatches name against a pattern case-insensitively with the following placeholders: %: matches any sequence of characters, including the empty string; _ matches exactly one character; \ can be used to escape the placeholders (use \ for a literal backslash)
name_not_containsname does not contain the specified value (case-sensitive)
name_starts_withname starts with the specified value (case-sensitive)
name_not_ends_withname does not end with the specified value (case-sensitive)

For more details about filtering on a specific type, look at its corresponding Filter type.

All Filters

This page was generated: 2024-05-17