2

例如:

apolloServer(request => ({
  schema: typeDefinitionArray,
  graphiql: true,
  context: request.session
}))

http://docs.apollostack.com/apollo-server/tools.html

我知道=>这意味着 es6 函数与 bound this,但()之后=>做什么?

4

1 回答 1

3

如果您跳过,()那么如果它是您想要返回的 lambda 的主体或对象文字,那么它将是模棱两可的。所以要么

apolloServer(request => {
  return {
    schema: typeDefinitionArray,
    graphiql: true,
    context: request.session
}})

或者

apolloServer(request => ({
  schema: typeDefinitionArray,
  graphiql: true,
  context: request.session
}))
于 2016-05-20T02:16:49.267 回答