graphql-middleware icon indicating copy to clipboard operation
graphql-middleware copied to clipboard

Checking __typename in middleware

Open andres-valdes opened this issue 5 years ago • 1 comments

Is there any way that I can extract the __typename of a resolver response in my middleware?

andres-valdes avatar Feb 10 '20 06:02 andres-valdes

Hmm, have you tried digging into the info argument? I know there's a lot of information there.

If you want to check the type of an object you are going to return and is already computed, how about you add a simple check that accesses the obj.__typename field and decides what to do? You might need to be a bit more cautious when it comes to your queries, as you might need to include that in every query, but you can resolve that using fragments.

https://github.com/maticzav/graphql-middleware#middleware-fragments

maticzav avatar May 23 '21 06:05 maticzav