Getting args passed to the parent resolver from field resolver #817
Replies: 3 comments 5 replies
-
It's not easily possible in GraphQL to pass parent args to childs because it's a bad design of the GraphQL API.
|
Beta Was this translation helpful? Give feedback.
5 replies
-
@ObjectType()
class Foo {
@Field()
foo: string;
bar?: string;
}
@Resolver(of => Foo)
class FooResolver
@Query(() => Foo)
getFoo(@Arg("bar") bar: string): Foo {
return { foo: "foo", bar }
}
@FieldResolver(() => String, { nullable: true })
foobar(@Root() foo: Foo): string | undefined {
return foo.bar;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MichalLytek
-
Thanks so much, @MichalLytek. Was able to figure out what was causing the error. Works fine now |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I have a resolver that has a filter args passed to it.
Now the tags have a count field that needs to be resolved separately because it requires some fetching data from other tables.
How do I get the filter passed in the tags query in the field resolver?
Beta Was this translation helpful? Give feedback.
All reactions