Help articles

Incompatible combination of params and filter

The reference field lets you define options for the input component: a GROQ filter and, optionally, parameters for that filter. Define the filter statically with filter and filterParams, or use a function to derive the filter from the surrounding document. You cannot do both. The Studio reports `filterParams` cannot be used if `filter` is a function. Either statically define `filter` as a string, or return `params` from the `filter`-function.

If you are encountering this error, it usually means that you've defined a function for deriving the filter, but has also defined a set of static parameters. The solution is to either use static values, or just use the filter function and return an object containing both the filter and the parameters:

export default {
  name: 'blogPost',
  type: 'document',
  fields: [
    // ... your other schema fields ...
    {
      name: 'author',
      type: 'reference',
      to: [{type: 'person'}],
      options: {
        filter: () => {
          return {
            filter: 'age > $age',
            params: {age: 30}
          }
        }
      }
    }
  ]
}

Was this page helpful?