【发布时间】:2021-01-25 12:26:18
【问题描述】:
可能是一个简单的问题,但我最初一直在使用 graphqlOperation 在 AWS Amplify 中进行 API 查询。最近我开始使用 Cognito 用户池。在我的一生中,我无法将authMode 传递给它并最终使用了普通查询。
## normal query - works
await API.graphql({query: listForms, authMode: 'AMAZON_COGNITO_USER_POOLS'});
## using graphqlOperation - does not work (Unauthorized)
await API.graphql(graphqlOperation(listForms, { authMode: 'AMAZON_COGNITO_USER_POOLS' }));
我可以使用普通查询,但我想知道如果普通查询似乎就足够了,你为什么还要使用 graphqlOperation 类?它们似乎都返回相同的有效载荷。大多数文档似乎都使用graphqlOperation 进行引用。我只是不确定它会带来什么好处。
谢谢! T
【问题讨论】:
标签: amazon-web-services graphql aws-amplify