小编lep*_*thy的帖子

Amplify 缺少 Cognito 自定义声明,但 Appsync 控制台没有

我有以下解析器,允许我检索有关当前用户公司的信息(companyId 作为自定义字段添加到 cognito 用户池中)。cognito 上的字段设置为可变的。

{ "version" : "2017-02-28", "operation" : "GetItem", "key": { "id" : $util.dynamodb.toDynamoDBJson($context.identity.claims.get("custom:companyId")) } }

——

这在使用 AWS AppSync 界面(登录后)时工作正常,如日志所示:

{ "errors": [], "mappingTemplateType": "Request Mapping", "path": "[getMyClientCompany]", "resolverArn": "arn:aws:appsync:eu-west-1:261378271140:apis/rue25cac6jc6vfbhvu32sjafqy/types/Query/fields/getMyClientCompany", "transformedTemplate": "{\n \"version\" : \"2017-02-28\",\n \"operation\" : \"GetItem\",\n \"key\": {\n \"id\" : {\"S\":\"0c1c81db-a771-4856-9a30-d11bf8e3cab1\"}\n }\n}", "context": { "arguments": {}, "source": null, "result": null, "error": null, "outErrors": [] }, "fieldInError": false }

——

但是当代码来自 Amplify-js 时不起作用:

{ "errors": [], "mappingTemplateType": "Request Mapping", "path": "[getMyClientCompany]", "resolverArn": "arn:aws:appsync:eu-west-1:261378271140:apis/rue25cac6jc6vfbhvu32sjafqy/types/Query/fields/getMyClientCompany", "transformedTemplate": "{\n …

claims-based-identity custom-attribute amazon-cognito aws-appsync aws-amplify

3
推荐指数
1
解决办法
1742
查看次数