Skip to content

Getting args passed to the parent resolver from field resolver #817

Answered by MichalLytek
Somtozech asked this question in Q&A
Discussion options

You must be logged in to vote
@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;
  }
}

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@Somtozech
Comment options

@MichalLytek
Comment options

@Somtozech
Comment options

@MichalLytek
Comment options

@MichalLytek
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by MichalLytek
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants