graphql-middleware
graphql-middleware copied to clipboard
Checking __typename in middleware
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