Skip to Content

WunderGraph Hooks Overview

Published: 2022-05-23

WunderGraph Hooks are an essential part to customize the Request Lifecycle of WunderGraph Applications.

In this section, you'll learn what Hooks are meant for and how to use them.

The Request Hooks LifeCycle#

  1. Request Handler begins
  2. Input Parsing
  3. JSON Schema Input Validation
  4. Claims Injection
  5. Mock Resolve (if configured)
  6. preResolve Hook
  7. mutatingPreResolve Hook
  8. customResolve Hook
  9. resolver
  10. onRequest Hook
  11. onResponse Hook
  12. postResolve Hook
  13. mutatingPostResolve Hook
  14. Sending Response to Client

Available Hooks#

Hooks are available in two categories. Mutating Hooks and non-Mutating Hooks.

Mutating Hooks, as the name suggests, directly influence the Request Chain. They can manipulate the inputs to an Operation or the response.

Non-Mutating Hooks on the other side simply receive the data currently available to the request chain, e.g. the user Object, inputs or a response.

Use Cases#

With non-Mutating Hooks, you're able to log specific events or invoke side effects, e.g. sending an Email after a mutation.

Mutating Hooks on the other hand are designed to react to the inputs, or the resolved response, based on the Request Context. E.g. you could define custom hook variables for filtering or use information about the user to filter or manipulate responses.


Product

Comparisons

Subscribe to our newsletter!

Stay informed when great things happen! Get the latest news about APIs, GraphQL and more straight into your mailbox.

© 2022 WunderGraph