WunderGraph supports claims, which allow you to declare and manipulate user attributes.
Well Known claims
Out of the box, WunderGraph understands several well known claims directly. The full list can be found in the documentation for the
WunderGraph also supports defining your custom claims and using them in the same as well known ones. First, define your custom claims when configuring your WunderGraph application:
Defining your custom claims allows to generate all the plumbing required to access them in a type-safe manner and get instant errors in your IDE if you accidentally misuse them.
Claims can be injected into any variable during a GraphQL operation using the
@fromClaim directive. In Typescript operations or client code, claims are available as part of the
User object. Well known claims are mapped to fields, while custom claims live below the
customClaims field in
Exposing claims from your API
By default, all well known and custom claims are exposed from the API, and the frontend can access them wherever a
User object is available (e.g. using
useUser()). To expose only a subset of them, define a list of
publicClaims when calling
Claim names are strongly typed, so your editor will autocomplete them in most cases.