Multiple directives not working the way i expected?

i have two directives, @authenticated and @permission.
@authenticated checks if the user is logged in or throws an error.
@permission accepts a “role” arg to check if the user has the permission to do something or throws an error.

i added the two to a mutation and it shows the error from @permission. i expected @authenticated to catch that and stop before even going to @permission.

how do directives work?

Some basic debugging first:

  1. If you remove the permission directive, does the authenticated directive work?
  2. Have done any logging/breakpoints to verify the order in which the directives are being executed?
  3. Can you just combine the two directives? The permission directive seems to assume the authenticated directive, so maybe you could just do the evaluations in a single directive?

thanks for the reply!

  1. Yes. i have a “me” query which retrieves the user’s info and @authenticated works with with it.
  2. will do that again. i tried changing the order, but that didn’t work. I’ll try to log which directive triggers first tmr.
  3. yes, that’s what im doing for now. i broke them into two because some other queries only require that the user is logged in to check the their own info (me, editme, etc.)

ok, i checked and the code for @authenticated from “fieldConfig.resolve” didn’t run. i console.log fieldConfig.resolve and it return resolves with no error. not sure why the code didn’t get executed tho, but if i commented out @permission, @authenticated throws the error.