我在无服务器graphql演示中看到了这样的一段代码
custom:
accountId: 1234xxxxxxxx # replace this with your accountId
appSync:
# name: # defaults to api
# apiId # only required for update-appsync
authenticationType: AMAZON_COGNITO_USER_POOLS # API_KEY is also supported
userPoolConfig:
awsRegion: us-east-1 # required # region
defaultAction: ALLOW
userPoolId: us-east-1_xxxxxxxxx # replace this with your Cognito User Pool Id
# region: # defaults to provider region
# mappingTemplatesLocation: # defaults to mapping-templates
mappingTemplates:
- dataSource: Lambda
type: Query
field: getUserInfo
request: "getUserInfo-request-mapping-template.txt"
response: "getUserInfo-response-mapping-template.txt"
- dataSource: Lambda
type: Query
field: meInfo
request: "meInfo-request-mapping-template.txt"
response: "meInfo-response-mapping-template.txt"
- dataSource: Lambda
type: Mutation
field: createTweet
request: "createTweet-request-mapping-template.txt"
response: "createTweet-response-mapping-template.txt"
- dataSource: Lambda
type: Mutation
field: deleteTweet
request: "deleteTweet-request-mapping-template.txt"
response: "deleteTweet-response-mapping-template.txt"
- dataSource: Lambda
type: Mutation
field: reTweet
request: "reTweet-request-mapping-template.txt"
response: "reTweet-response-mapping-template.txt"
# schema: # defaults schema.graphql
serviceRole: "AppSyncServiceRole"
dataSources:
- type: AWS_LAMBDA
name: Lambda
description: 'Lambda DataSource'
config:
lambdaFunctionArn: "arn:aws:lambda:us-east-1:${self:custom.accountId}:function:serverless-graphql-appsync-lda-production-graphql"
serviceRoleArn: "arn:aws:iam::${self:custom.accountId}:role/Lambda-${self:custom.appSync.serviceRole}"
serverless-offline:
port: 4000
webpackIncludeModules: true
functions:
graphql:
handler: handler.graphqlHandler
events:
- http:
path: graphql
method: POST
mappingTemplates下的字段对应于grahql的解析器。这会将每个接口拆分为lambda函数吗? 该性能优于下面的总体graphql条目?更经济吗?
functions:
graphql:
handler: handler.graphqlHandler
events:
- http:
path: graphql
method: POST
谢谢