例如:
apolloServer(request => ({
schema: typeDefinitionArray,
graphiql: true,
context: request.session
}))
http://docs.apollostack.com/apollo-server/tools.html
我知道=>
这意味着 es6 函数与 bound this
,但()
之后=>
做什么?
例如:
apolloServer(request => ({
schema: typeDefinitionArray,
graphiql: true,
context: request.session
}))
http://docs.apollostack.com/apollo-server/tools.html
我知道=>
这意味着 es6 函数与 bound this
,但()
之后=>
做什么?
如果您跳过,()
那么如果它是您想要返回的 lambda 的主体或对象文字,那么它将是模棱两可的。所以要么
apolloServer(request => {
return {
schema: typeDefinitionArray,
graphiql: true,
context: request.session
}})
或者
apolloServer(request => ({
schema: typeDefinitionArray,
graphiql: true,
context: request.session
}))