Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking __typename in middleware #248

Open
andres-valdes opened this issue Feb 10, 2020 · 1 comment
Open

Checking __typename in middleware #248

andres-valdes opened this issue Feb 10, 2020 · 1 comment
Labels
kind/question Developer asked a question. No code changes required.

Comments

@andres-valdes
Copy link

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

@maticzav
Copy link
Owner

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 maticzav added the kind/question Developer asked a question. No code changes required. label May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Developer asked a question. No code changes required.
Projects
None yet
Development

No branches or pull requests

2 participants