cancel
Showing results for 
Search instead for 
Did you mean: 

Computed Property from JWT e.g. tid

Hi,

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.

2 REPLIES 2

ThomasWiss
Node

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?

Thomas,

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 👍