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

Question: adding middleware around a (mock) type resolver? #257

Open
jrnail23 opened this issue May 30, 2020 · 1 comment
Open

Question: adding middleware around a (mock) type resolver? #257

jrnail23 opened this issue May 30, 2020 · 1 comment
Labels
kind/question Developer asked a question. No code changes required.

Comments

@jrnail23
Copy link

jrnail23 commented May 30, 2020

I've been able to successfully apply middleware for fields, but when I try to apply one to a type resolver, it only applies the middleware to that type's field resolvers, not the type resolver itself.
Is there a way to only have it apply to the type resolver?
For example, given the below resolvers, I'd like to wrap the Contact type resolver, but I can only seem to get it to apply to that type's fields (e.g, name below).

// RESOLVERS
{
  // mock type resolver
  Contact: () => {
    return {
      name: () => { /* field resolver */ }
    }
  },
  Query: () => {
    contacts: () => { /* field resolver */ }
  }
}
// MIDDLEWARE
applyMiddleware(schema, {
  Contact: myMiddleware()
})
@jrnail23 jrnail23 changed the title Question: adding middleware around a type resolver? Question: adding middleware around a (mock) type resolver? May 30, 2020
@maticzav
Copy link
Owner

Hi @jrnail23 👋 ,

Could you explain in a bit more detail what a type-resolver would do? Maybe you could do some mocking by checking the name of the field? You can get that information from the info argument in the middleware.

@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