Accessing JWT variables within @custom mutations

According to example given in I can access JWT variables within @auth() queries.
Can I use those JWT variables within @custom() mutations, so example could be rewritten as:

type Mutation {
    newPost(title: String!, text: String, $USER: String!): Post @custom(http:{
        url: ""
        method: "POST",
        body: "{ postText: $text, postTitle: $title, author: $USER }"
        forwardHeaders: ["AuthHdr"]

I know I can forward Auth headers and extract the USER at the API endpoint, but accessing JWT variables at @custom() mutation definition could be easier.


A use case for this would be defining the url based upon the JWT.

1 Like

We don’t allow accessing JWT variables inside custom mutations as of now. We will try to discuss that internally and see if we can have them soon.


We have discussed this internally and have come up with a couple of ways to achieve this.

  1. It should be possible for you to forward the JWT header to the custom endpoint and extract the variables there.
  2. This would also become possible when we introduce pre and post Javascript hooks where the JWT variables would be available to you under the context.
1 Like