Using Conditions in GraphQL Queries

Conditions are used to control what results are return

  • distinct_on - return unique results from the value of a specified attribute
  • limit - limit the number of rows returned
  • offset - skip the specified number of results
  • order_by - sort the rows by one or more columns
  • where - filter results based on the value of specified attributes

Conditions Basic form

Conditions are defined as arguments to the field in the query.

type query_root {
  live_match_event(
  distinct_on: [live_match_event_select_column!],
  limit: Int,
  offset: Int,
  order_by: [live_match_event_order_by!],
  where: live_match_event_bool_exp
  )
}

Defining Variables

Dynamic values can be defined using Variables to make queries easier to work with.

Distinct results

A distinct_on condition for a specified field will return a unique set of results based on the values of that field.

For example, searching for a Player can return the same result multiple times, found across multiple match line-ups. Using distinct_on for the player_id filed will ensure that only distinct results are returned for that player_id.

Limit number of results

Using limits can make your queries return results faster, as the query will return once the number of results in the limit has been reached.

limit takes an integer number that sets the maximum number of results to return from any query.

Default limits

The LIVE Data API is limited to 4,200 events for queries, with a further limit of 200 on aggregated stats

Offset results

offset takes an integer number which defines the number of results to skip.

For example, if there are 50 events per minute in a game and are only interested in events after the first 10 minutes. Set an offset value of 500 would skip results from approximately the first 10 minutes.

Order results by a value

Return the results of the query sorted by the value of the attribute specified

Examples Order matches by date

where

Use where in queries to filter results based on some field’s values You can even use multiple filters in the same where clause using the _and or the _or operators.

Equality

  • _eq equal to a value of a field
  • _neq not equal to a value of a field
  • _gt greater than
  • _lt less than
  • _gte greater than or equal to
  • _lte less than or equal to

Hint

the _eq or _neq operators will not return rows with null values. Use the `_is_null** operator to match on null values.

List Based Searching

  • _in in a list
  • `_nin** not in a list

Text searching Use the following to search for a string match. Use % as a wildcard that represents one or more characters in the string.

  • _like field string is like pattern
  • _nlike field string is not like pattern
  • _ilike field string is like pattern - case insensitive
  • _nilike field string is like pattern - case insensitive
  • _similar string similar to one or more patterns "%(United|City)" - team name ending in United or City
  • _nsimilar string not similar to one or more patterns
  • _regex regular expression pattern matching
  • _nregex not a match for regular expression pattern
  • _iregex regular expression pattern matching - case insensitive
  • _inregex not a match for regular expression pattern

results matching ""

    No results matching ""