mirror of
https://github.com/jbranchaud/til
synced 2026-01-08 17:48:01 +00:00
Add Include Type Of Operation In Webhook Response as a GROQ til
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1195 TILs and counting..._
|
_1196 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -340,6 +340,7 @@ _1195 TILs and counting..._
|
|||||||
### GROQ
|
### GROQ
|
||||||
|
|
||||||
- [Grab Values From An Array Of References](groq/grab-values-from-an-array-of-references.md)
|
- [Grab Values From An Array Of References](groq/grab-values-from-an-array-of-references.md)
|
||||||
|
- [Include Type Of Operation In Webhook Response](groq/include-type-of-operation-in-webhook-response.md)
|
||||||
|
|
||||||
### Heroku
|
### Heroku
|
||||||
|
|
||||||
|
|||||||
26
groq/include-type-of-operation-in-webhook-response.md
Normal file
26
groq/include-type-of-operation-in-webhook-response.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Include Type Of Operation In Webhook Response
|
||||||
|
|
||||||
|
When setting up a webhook in Sanity Studio, you can specify what types of
|
||||||
|
operations you want to trigger the webhook: `create`, `update`, and `delete`.
|
||||||
|
|
||||||
|
If you include all three for a webhook, then you'll probably want to know in
|
||||||
|
your webhook handler which type of operation you're receiving.
|
||||||
|
|
||||||
|
Webhooks are run in _Delta Mode_ which means that a collection of GROQ
|
||||||
|
functions are available in the _filter_ and _projection_ blocks. These
|
||||||
|
functions include
|
||||||
|
[`delta::operation`](https://www.sanity.io/docs/groq-functions#a64594a50318).
|
||||||
|
|
||||||
|
Here is what a projection using `delta::operation` might look like:
|
||||||
|
|
||||||
|
```groq
|
||||||
|
{
|
||||||
|
_id,
|
||||||
|
firstName,
|
||||||
|
lastName,
|
||||||
|
email,
|
||||||
|
'operation': delta::operation()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This function can resolve to either `create`, `update`, or `delete`.
|
||||||
Reference in New Issue
Block a user