We use cookies to help our site work and to understand how it is used. By continuing to browse the site you're agreeing to our use of cookies.
Menu

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
  }
}

Filtering by record ID

eq
Search the record with the specified ID
query {
  allProducts(filter: { id: { eq: "123" } }) {
    title
  }
}
neq
Exclude the record with the specified ID
query {
  allProducts(filter: { id: { neq: "123" } }) {
    title
  }
}
in
Search records with the specified IDs
query {
  allProducts(filter: { id: { in: ["123"] } }) {
    title
  }
}

Filtering by position

eq
Search for records with an exact match
query {
  allProducts(filter: { position: { eq: 3 } }) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(filter: { position: { neq: 3 } }) {
    title
  }
}
gt
Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { position: { gt: 3 } }) {
    title
  }
}
gte
Filter records with a value that's greater than or equal to the one specified
query {
  allProducts(filter: { position: { gte: 3 } }) {
    title
  }
}
lt
Filter records with a value that's less than the one specified
query {
  allProducts(filter: { position: { lt: 3 } }) {
    title
  }
}
lte
Filter records with a value that's less or equal than the one specified
query {
  allProducts(filter: { position: { lte: 3 } }) {
    title
  }
}

Filtering by parent

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

Single-line string fields

eq
Search for records with an exact match
query {
  allProducts(filter: { name: { eq: "bike" } }) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(filter: { name: { neq: "bike" } }) {
    title
  }
}
in
Filter records that have one of the specified values
query {
  allProducts(filter: { name: { in: ["bike"] } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { name: { exists: true } }) {
    title
  }
}
matches
Filter records based on a regular expression
query {
  allProducts(
    filter: {
      name: {
        matches: { pattern: "bi(cycl|k)e", caseSensitive: false }
      }
    }
  ) {
    title
  }
}
notMatches
Exclude records based on a regular expression
query {
  allProducts(
    filter: {
      name: {
        notMatches: { pattern: "bi(cycl|k)e", caseSensitive: false }
      }
    }
  ) {
    title
  }
}

Integer fields

eq
Search for records with an exact match
query {
  allProducts(filter: { rating: { eq: 3 } }) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(filter: { rating: { neq: 3 } }) {
    title
  }
}
gt
Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { rating: { gt: 3 } }) {
    title
  }
}
gte
Filter records with a value that's greater than or equal to the one specified
query {
  allProducts(filter: { rating: { gte: 3 } }) {
    title
  }
}
lt
Filter records with a value that's less than the one specified
query {
  allProducts(filter: { rating: { lt: 3 } }) {
    title
  }
}
lte
Filter records with a value that's less or equal than the one specified
query {
  allProducts(filter: { rating: { lte: 3 } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { rating: { exists: true } }) {
    title
  }
}

Boolean fields

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

Floating-point fields

eq
Search for records with an exact match
query {
  allProducts(filter: { price: { eq: 19.99 } }) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(filter: { price: { neq: 19.99 } }) {
    title
  }
}
gt
Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { price: { gt: 19.99 } }) {
    title
  }
}
gte
Filter records with a value that's greater than or equal to the one specified
query {
  allProducts(filter: { price: { gte: 19.99 } }) {
    title
  }
}
lt
Filter records with a value that's less than the one specified
query {
  allProducts(filter: { price: { lt: 19.99 } }) {
    title
  }
}
lte
Filter records with a value that's less or equal than the one specified
query {
  allProducts(filter: { price: { lte: 19.99 } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { price: { exists: true } }) {
    title
  }
}

Date fields

eq
Search for records with an exact match
query {
  allProducts(filter: { publishedAt: { eq: "2018-02-13" } }) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(filter: { publishedAt: { neq: "2018-02-13" } }) {
    title
  }
}
gt
Filter records with a value that's strictly greater than the one specified
query {
  allProducts(filter: { publishedAt: { gt: "2018-02-13" } }) {
    title
  }
}
gte
Filter records with a value that's greater than or equal to the one specified
query {
  allProducts(filter: { publishedAt: { gte: "2018-02-13" } }) {
    title
  }
}
lt
Filter records with a value that's less than the one specified
query {
  allProducts(filter: { publishedAt: { lt: "2018-02-13" } }) {
    title
  }
}
lte
Filter records with a value that's less or equal than the one specified
query {
  allProducts(filter: { publishedAt: { lte: "2018-02-13" } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { publishedAt: { exists: true } }) {
    title
  }
}

DateTime fields

eq
Search for records with an exact match
query {
  allProducts(
    filter: {
      promoStartsAt: {
        eq: "2018-02-13T14:30:00+00:00"
      }
    }
  ) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(
    filter: {
      promoStartsAt: {
        neq: "2018-02-13T14:30:00+00:00"
      }
    }
  ) {
    title
  }
}
gt
Filter records with a value that's strictly greater than the one specified
query {
  allProducts(
    filter: {
      promoStartsAt: {
        gt: "2018-02-13T14:30:00+00:00"
      }
    }
  ) {
    title
  }
}
gte
Filter records with a value that's greater than or equal to than the one specified
query {
  allProducts(
    filter: {
      promoStartsAt: {
        gte: "2018-02-13T14:30:00+00:00"
      }
    }
  ) {
    title
  }
}
lt
Filter records with a value that's less than the one specified
query {
  allProducts(
    filter: {
      promoStartsAt: {
        lt: "2018-02-13T14:30:00+00:00"
      }
    }
  ) {
    title
  }
}
lte
Filter records with a value that's less or equal than the one specified
query {
  allProducts(
    filter: {
      promoStartsAt: {
        lte: "2018-02-13T14:30:00+00:00"
      }
    }
  ) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { promoStartsAt: { exists: true } }) {
    title
  }
}

Single-file/image fields

eq
Search for records with an exact match. The specified value must be an Upload ID
query {
  allProducts(filter: { image: { eq: "123" } }) {
    title
  }
}
neq
Exclude records with an exact match. The specified value must be an Upload ID
query {
  allProducts(filter: { image: { neq: "123" } }) {
    title
  }
}
in
Filter records that have one of the specified uploads
query {
  allProducts(filter: { image: { in: ["123"] } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { image: { exists: true } }) {
    title
  }
}

Multiple files/images field

eq
Search for records with an exact match. The specified values must be Upload IDs
query {
  allProducts(filter: { galleryImages: { eq: ["123"] } }) {
    title
  }
}
allIn
Filter records that have all of the specified uploads. The specified values must be Upload IDs
query {
  allProducts(filter: { galleryImages: { allIn: ["123"] } }) {
    title
  }
}
anyIn
Filter records that have one of the specified uploads. The specified values must be Upload IDs
query {
  allProducts(filter: { galleryImages: { anyIn: ["123"] } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { galleryImages: { exists: true } }) {
    title
  }
}

Video fields

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

Color fields

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

Geolocation fields

near
Filter records within the specified radius
query {
  allProducts(
    filter: {
      location: {
        near: { latitude: 40.73, longitude: -73.93, radius: 10 }
      }
    }
  ) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { location: { exists: true } }) {
    title
  }
}

SEO meta tags fields

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

Slug fields

eq
Search for records with an exact match
query {
  allProducts(filter: { slug: { eq: "bike" } }) {
    title
  }
}
neq
Exclude records with an exact match
query {
  allProducts(filter: { slug: { neq: "bike" } }) {
    title
  }
}
in
Filter records that have one of the specified slugs
query {
  allProducts(filter: { slug: { in: ["bike"] } }) {
    title
  }
}

Single-link fields

eq
Search for records with an exact match. The specified value must be a Record ID
query {
  allProducts(filter: { author: { eq: "123" } }) {
    title
  }
}
neq
Exclude records with an exact match. The specified value must be a Record ID
query {
  allProducts(filter: { author: { neq: "123" } }) {
    title
  }
}
in
Filter records linked to one of the specified records
query {
  allProducts(filter: { author: { in: ["123"] } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { author: { exists: true } }) {
    title
  }
}

Multiple-links fields

eq
Search for records with an exact match. The specified values must be Record IDs
query {
  allProducts(filter: { categories: { eq: ["123"] } }) {
    title
  }
}
allIn
Filter records linked to all of the specified records. The specified values must be Record IDs
query {
  allProducts(filter: { categories: { allIn: ["123"] } }) {
    title
  }
}
anyIn
Filter records linked to at least one of the specified records. The specified values must be Record IDs
query {
  allProducts(filter: { categories: { anyIn: ["123"] } }) {
    title
  }
}
exists
Filter records with the specified field defined (i.e. with any value) or not
query {
  allProducts(filter: { categories: { exists: true } }) {
    title
  }
}

JSON fields

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