Replies: 1 comment 2 replies
-
This could be done through a custom validation rule. It probably needs to be configured with pairs of fields that are the inverse of each other, since that does not necessarily follow from the schema definition. Consider the following example: "Represents a node in a tree, see https://en.wikipedia.org/wiki/Tree_(abstract_data_type)."
type TreeNode {
parent: TreeNode
children: [TreeNode!]!
siblings: [TreeNode!]!
} Considering the shape of a tree, |
Beta Was this translation helpful? Give feedback.
2 replies
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.
-
Hi,
What are recommended practices if you have type tree which eventually can reference each other?
Assumme I've an
Article
and aComment
and I have queries likearticlesList
andcommentsList
andArticle
has comments but aComment
can also reference it's article.Intended use cases:
or
It's now possible to also do this:
I'm aware of:
\GraphQL\Validator\Rules\QueryComplexity
andsetMaxQueryComplexity
\GraphQL\Validator\Rules\QueryDepth
andsetMaxQueryDepth
But they need to be adjusted to their maxima I need for legitimate queries, of which I also have some, which needs higher values then for the example I gave.
I'm also aware with a proper data loader in place this shouldn't be a problem (n+1 problem), but I am looking at a different kind of protection.
Something which is looking at the types and is configurable to detect if e.g.
article
is already accessed in different levels in the tree and then thrown an error.A recommendations to have something similar to
QueryComplexity
andQueryDepth
but more targeted?thanks!
Beta Was this translation helpful? Give feedback.
All reactions