在 GraphQL 中获取父级的子参数

Get child args in parent in GraphQL

我有如下所述的 graphQL 查询

{ parent { child(childArgs: "myname") } } }

我想访问父级的childArgs值,有什么方法可以访问父级的childArgs。

是的,使用 resolveInfo argument to your resolver function you can check whether the child field is queried on your parent object and what arguments it will have. Given you have to work with the query AST (and might have to resolve variables etc), I recommend using the grapqhl-parse-resolve-info package