You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m using @envelop/generic-auth in my GraphQL Yoga server, following this example. I’ve set mode to protect-granular, expecting the resolveUserFn to only be called for fields marked with the @authenticated directive. However, I noticed that resolveUserFn is being called for all fields, including public fields that don’t require authentication.
This behavior adds unnecessary overhead for fields that don’t need user resolution or validation.
What I was expecting:
In protect-granular mode:
resolveUserFn should only be invoked for fields marked with the @authenticated directive.
Public fields should bypass user resolution and validation.
Actual Behavior
resolveUserFn is executed for all fields, including public fields, leading to unnecessary overhead.
useGenericAuth({mode: 'protect-granular',asyncresolveUserFn(context){consttoken=context.request.headers.get('x-authorization');// further validations: decoding, getting user deails from db e.t.c.returntoken??null;},});
Query:
query {
public
}
Observe that resolveUserFn is called for the public field.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m using
@envelop/generic-authin my GraphQL Yoga server, following this example. I’ve setmodetoprotect-granular, expecting theresolveUserFnto only be called for fields marked with the@authenticateddirective. However, I noticed thatresolveUserFnis being called for all fields, including public fields that don’t require authentication.This behavior adds unnecessary overhead for fields that don’t need user resolution or validation.
What I was expecting:
In
protect-granularmode:resolveUserFnshould only be invoked for fields marked with the@authenticateddirective.Actual Behavior
resolveUserFnis executed for all fields, including public fields, leading to unnecessary overhead.Reproduction
Schema:
Plugin setup in GraphQL Yoga:
Query:
Observe that
resolveUserFnis called for thepublicfield.any thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions