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

Wrong resolve argument in nested types

Open hassenc opened this issue 5 years ago • 2 comments

Hello !

I have the following resolvers, (schema created with makeExecutableSchema)

const resolvers = {
  Muation: {
    viewerMutation: (_, args, context) => {
      book: () => {
          author: ({id}) => getAuthorForBook(id)
      }  
    },
  },
}

And I am trying to do something like this:

const logMiddleware = {
  Muation: {
    viewerMutation: async (resolve, parent, args, context, info) => {
      book: () => {
          author: ({id}) => {
               console.log('request author for book:', id)
               return resolve(root, {id}, context, info)
          }
      }  
    },
  },
}

But I am getting an issue, the resolve inside author is not calling getAuthorForBook. I would have expected to find a resolver argument on author but nested types seem to behave differently from root types (under Mutation or Query) Is this a normal behavior ?

hassenc avatar Aug 27 '19 20:08 hassenc

I am having a similar issue

theluk avatar Oct 18 '19 22:10 theluk

Hi @hassenc @theluk 👋 ,

Thank you for being so patient with this issue. I have the capacity to help you with the problem; I only need the reproduction CodeSandbox or something similar. This way, I can help you more quickly.

maticzav avatar May 23 '21 06:05 maticzav