Skip to Content

WunderGraph Directives Overview

Published: September 09, 2021

Directives are a way of configuring the behaviour of your API straight from the Operation Definition.

Here's an example using two handy directives:

mutation (
$name: String! @fromClaim(name: NAME)
$email: String! @fromClaim(name: EMAIL)
$message: String! @jsonSchema(
pattern: "^[a-zA-Z 0-9]+$"
createOnepost(data: {message: $message user: {connectOrCreate: {where: {email: $email} create: {email: $email name: $name}}}}){
user {

This example uses the @fromClaim directive to inject Claims into the operation. Additionally, it's using the @jsonSchema directive to set a Regex pattern for the $message variable.

@fromClaim Directive#

Using this directive, you're able to inject Claims into an Operation. (read more)

@jsonSchema Directive#

With this directive, you're able to configure input validation rules for the Operation. (read more)


Subscribe to our newsletter!

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

© 2021 WunderGraph