maticzav / graphql-middleware

Split up your GraphQL resolvers in middleware functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checking __typename in middleware

andres-valdes opened this issue · comments

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

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