Skip to content

Accessing parent resolver args #1015

Answered by hayes
codepunkt asked this question in Q&A
Sep 7, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

There isn't a great way to do this. This is more of a general GraphQL issue than something specific to pothos.

There are 2 ways you can get those arguments:

  • You can pass them down by attaching them to the value returned from the resolver. If you are trying to pass it down several layers this can get pretty annoying
  • You can extract the arguments from the query using the info object (4th argument of a resolver). This isn't straight forward, and requires you to manually find the right selection, and then use the getArgumentValues helper from graphql to extract the arguments. This also will bypass certain things like validation, and parsing logic in resolvers, for example the decoding of glo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@codepunkt
Comment options

@hayes
Comment options

Answer selected by codepunkt
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