Tags: Sanity

Sanity and GROQ-powered webhooks are great, but there is a bug!

Sanity recently launched their GROQ-powered webhooks, and they are really powerful! There is even a guide that explains projections, and one that explains filters.

The bug

I created a simple webhook like this, that posts a message to Slack whenever a new document of type user is created.

Grafisk brukergrensesnitt, for å sette opp en Sanity webhook

When I later updated the webhook to only run for the production dataset, using the top drop-down, the webhook continued to fire on all datasets.

The workaround

One possible solution is doing the dataset filtering in GROQ, and not with the dropdown.

Grafisk brukergrensesnitt for Sanity webhook med filtrering på dataset

With this update, the webhook is only triggered for the production dataset.

Fixed

As of January 19th 2022, the bug is fixed and the workaround is no longer needed.