【问题标题】:graphql , understanding _ in resolve function in new GraphQLObjectTypegraphql ,在新 GraphQLObjectType 的解析函数中理解 _
【发布时间】:2017-07-16 17:48:44
【问题描述】:

解析函数中的“_”参数是什么意思?这是干什么用的?

const queryType = new GraphQLObjectType({
    name: 'RootQuery',
    fields: {
        usersCount: {
            type: GraphQLInt,
            resolve: (_, args, { db }) =>
                db.collection('users').count()
        }
    }
});

在哪里可以阅读有关解析参数的文档?

【问题讨论】:

    标签: graphql-js


    【解决方案1】:

    "_" 只是分配任何东西,因为不会使用这个参数。

    resolve:    (root, args, context, info) => ...
    

    阅读更多:

    https://github.com/graphql/graphql-js/issues/844

    【讨论】:

      猜你喜欢
      • 2017-09-19
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      • 2020-02-11
      • 2017-11-29
      • 2016-12-12
      • 1970-01-01
      • 2017-08-13
      相关资源
      最近更新 更多