You're reading "Content Delivery API"

Filtering records

You can supply different parameters to the filter argument to filter the query response accordingly. The available options depend on the fields defined on the model in question.

If you supply exactly one parameter to the filter argument, the query response will only contain records that fulfill this constraint:

query {
  allArtists(
    filter: {
      published: { eq: false }
    }
  ) {
    id
    name
    published
  }
}

Depending on the type of the field you want to filter by, you have access to different advanced criteria you can use to filter your query response:

query {
  allArtists(
    filter: {
      name: { in: [ "Blank Banshee", "Gazelle Twin" ] }
    }
  ) {
    id
    name
    genre
  }
}

If you specify multiple conditions, they will be combined in a logical AND expression:

query {
  allAlbums(
    filter: {
      { artist: { eq: "212" } },
      { releaseDate: { gt: "2016-01-01" } }
    }
  ) {
    id
    slug
    artist { name }
    coverImage { url }
  }
}

You can also combine AND and OR logical expressions. For example, the following query will return all the point of interest located in New York that either have a rating greater than 4 or are a restaurant:

query {
  allPois(
    filter: {
      address: { matches: { pattern: "new york" } },
      OR: [
        { rating: { gt: 4 } },
        { name: { matches: { pattern: "restaurant" } } },
      ]
    }
  ) {
    name
    address
    rating
  }
}

Meta fields

Filter by _created_at meta field

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { _created_at: { gt: "2018-02-13T14:30:00+00:00" } }) {
    title
  }
}

Filter by id meta field

Search the record with the specified ID
query {
  allProducts(filter: { id: { eq: "123" } }) {
    title
  }
}

Filter by _first_published_at meta field

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { _first_published_at: { gt: "2018-02-13T14:30:00+00:00" } }) {
    title
  }
}

Filter by parent meta field

Filter records children of the specified record. Value must be a Record ID
query {
  allProducts(filter: { parent: { eq: "123" } }) {
    title
  }
}

Filter by position meta field

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { position: { gt: 3 } }) {
    title
  }
}

Filter by _publication_scheduled_at meta field

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { _publication_scheduled_at: { gt: "2018-02-13T14:30:00+00:00" } }) {
    title
  }
}

Filter by _published_at meta field

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { _published_at: { gt: "2018-02-13T14:30:00+00:00" } }) {
    title
  }
}

Filter by _status meta field

Search the record with the specified status
query {
  allProducts(filter: { _status: { eq: draft } }) {
    title
  }
}

Filter by _updated_at meta field

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { _updated_at: { gt: "2018-02-13T14:30:00+00:00" } }) {
    title
  }
}

Filters available per field type

Boolean fields

Search for records with an exact match
query {
  allProducts(filter: { boolean: { eq: true } }) {
    title
  }
}

Color fields

Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { color: { exists: true } }) {
    title
  }
}

Date fields

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { date: { gt: "2018-02-13" } }) {
    title
  }
}

DateTime fields

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { date_time: { gt: "2018-02-13T14:30:00+00:00" } }) {
    title
  }
}

Single file fields

Search for records with an exact match. The specified value must be an Upload ID
query {
  allProducts(filter: { file: { eq: "123" } }) {
    title
  }
}

Floating-point number fields

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { float: { gt: 19.99 } }) {
    title
  }
}
Search for records with an exact match. The specified values must be Upload IDs
query {
  allProducts(filter: { gallery: { eq: ["123"] } }) {
    title
  }
}

Integer number fields

Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { integer: { gt: 3 } }) {
    title
  }
}

JSON fields

Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { json: { exists: true } }) {
    title
  }
}

Geolocation fields

Filter records within the specified radius
query {
  allProducts(
    filter: {
      lat_lon: {
        near: { latitude: 40.73, longitude: -73.93, radius: 10 }
      }
    }
  ) {
    title
  }
}
Search for records with an exact match. The specified value must be a Record ID
query {
  allProducts(filter: { link: { eq: "123" } }) {
    title
  }
}
Search for records with an exact match. The specified values must be Record IDs
query {
  allProducts(filter: { links: { eq: ["123"] } }) {
    title
  }
}

SEO meta tags fields

Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { seo: { exists: true } }) {
    title
  }
}

Slug fields

Search for records with an exact match
query {
  allProducts(filter: { slug: { eq: "bike" } }) {
    title
  }
}

Single-line string fields

Filter records based on a regular expression
query {
  allProducts(
    filter: {
      string: {
        matches: { pattern: "bi(cycl|k)e", caseSensitive: false }
      }
    }
  ) {
    title
  }
}

Multiple-paragraph text fields

Filter records based on a regular expression
query {
  allProducts(
    filter: {
      text: {
        matches: { pattern: "bi(cycl|k)e", caseSensitive: false }
      }
    }
  ) {
    title
  }
}

Video fields

Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { video: { exists: true } }) {
    title
  }
}
Go ahead to: Ordering records
Feel like something is missing in this page?
, submit an issue or propose a change on Github!