Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Computed Property from JWT e.g. tid


I am using GraphQL library for Neo4j.

How can I define a property on a type (e.g. tenantId: String!) which will take its value from the 'tid' property of the jwt auth token?

I currently use a '@bind' on the $jwt.sub but ideally, the 'tenantId' field will not appear in generated queries/mutations - I'm hoping the '@computed' directive can achieve all of this but I don't see how to define the property on the type to compute the field from the jwt property...

Any help appreciated - thanks.



Hi Adrian!

One way that came to mind which you may be able to solve this is by using the "@callback" directive. The jwt token can then be accessed via the "context" argument (something like "context.jwt.tid"), see this example.

Would this help in your case?


Thanks! That looks like a potential solution. I think I have Apollo configured to include the jwt in the context so that may work.

I'll give it a try and update here 👍