Graphql-yoga: What's the underscore _ parameter in the resolver function signature?

Created on 23 Jan 2018  路  2Comments  路  Source: dotansimha/graphql-yoga

Couldn't find any info on the underscore parameter seen in the examples and is undefined when logged.

What's it for?

const resolvers = {
  Query: {
    hello: (_, { name }) => `Hello ${name || 'World'}`,
  },
}
kinquestion

Most helpful comment

It's a placeholder for parent. In field-level resolvers, it contains the results of the parent resolver.
The full signature for a resolver function is (parent, args, context, info) => {}

All 2 comments

It's a placeholder for parent. In field-level resolvers, it contains the results of the parent resolver.
The full signature for a resolver function is (parent, args, context, info) => {}

Ah gotcha - thanks @kbrandwijk, makes sense!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SebastianEdwards picture SebastianEdwards  路  4Comments

cj picture cj  路  3Comments

yesprasad picture yesprasad  路  3Comments

2wce picture 2wce  路  4Comments

chakrihacker picture chakrihacker  路  5Comments