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:
- If you remove the
permission
directive, does the authenticated
directive work?
- Have done any logging/breakpoints to verify the order in which the directives are being executed?
- 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?
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.