✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Incompatible combination of params and filter

The reference field allows you to define options for the input component, namely a GROQ filter and a set of parameters for this filter. You can either define the filter statically, OR you can use a function in order to derive the filter based on the surrounding document.

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 article helpful?