| Q | A
| ---------------- | -----
| Bug report? | no
| Feature request? | no
| BC Break report? | no
| RFC? | no
| Version/Branch | master
i am trying to do some nested resolver.
schema:
Query:
type: object
config:
description: "Articles"
fields:
post:
type: "Post"
resolve: "@=resolver('Post', [args])"
args:
id:
description: "the article id"
type: "Int"
post:
Post:
type: object
config:
description: "Article"
fields:
id:
type: "Int!"
description: "the unique id of the post"
title:
type: "String"
description: "Title"
something:
type: "Post"
resolve: "@=resolver('Post', [args])"
args:
id:
description: "Post ID"
type: "Int"
running query:
{
post(id: 1789935) {
something(id: 10407) {
title
}
id
title
}
}
return:
{
"data": {
"post": {
"something": {
"title": "Life of Agony live in Wien"
},
"title": "Huawei Mate 20 (Pro) kommt mit Monster-Akku und KI"
}
}
}
in the something field, the resolver has access to args - but is there a way to access the parent's value - like i would to have access to the title and id from the outer resolver.
like inside Life of Agony live in Wien id like to know Huawei Mate 20 (Pro) kommt mit Monster-Akku und KI
i tried it with:
something:
type: "Post"
resolve: "@=resolver('Post', [value, args])"
args:
id:
description: "Post ID"
type: "Int"
but that fails with:
Argument 1 passed to App\\GraphQL\\Resolver\\PostResolver::resolve() must be an instance of Overblog\\GraphQLBundle\\Definition\\Argument, instance of KRNApiBundle\\Models\\PostModel
any advice?
btw thx for creating/maintaining this bundle its super awesome i love it 鉂わ笍
Hi it seems that your resolver arguments is not properly ordered:
something:
type: "Post"
resolve: "@=resolver('Post', [value, args])" # here
args:
id:
description: "Post ID"
type: "Int"
try @=resolver('Post', [args, value])"
@mcg-web ohhh wow, thx, i feel dumb now! many thx, it works, sorry for wasting your time.
Most helpful comment
@mcg-web ohhh wow, thx, i feel dumb now! many thx, it works, sorry for wasting your time.