Relay node with scope auth #1065
-
Hi I just wonder if there is anyway that I can use currently I have builder setup as
and trying to write a relay node
but now even without the scopes present, the loadOne function is still got called. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Type level scopes get run after the node is loaded, meaning that loadOne would always be called. This is basically because many scopes need to access information about the node to know if it should be authorized. If you want to run auth checks before loading, it needs to be done on the node/nodes query fields. You can add this via relayOptions.node(s)FieldOptions.authScopes in the builder options |
Beta Was this translation helpful? Give feedback.
There are 2 options:
You can define a scope on the node/nodes field using a callback so you have access to the id(s) arg, which should let you get the typename and apply checks based on the type.
Alternatively you can add a check inside the loadOne method using
await builder.runAuthScopes(context, scopes)