Current depth in afterRead hook #7753
dkirchhof
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I tried to use the afterRead hook to reduce the data which will be returned from the api.
Example:
I have an articles collection with a blocks field called "content". If I fetch the article it should return all data (blocks array included).
A relationship field can link one article to another. The nested article should return an empty blocks array. Can't reduce the depth because I need the slug of this article etc.
Right now, I check, if some variables are set in the
args.context
object. If so, I return an empty array if not I set the variable.Another approach was to use the
args.findMany
flag.Well, in most cases the solution works fine but there could be a better approach.
currentDepth
could be passed to the hook so you can checkargs.currentDepth > 0
Beta Was this translation helpful? Give feedback.
All reactions