【发布时间】:2020-05-01 17:42:27
【问题描述】:
我正在将 Amplify 和 Appsync 用于我正在构建的 React 应用程序。现在我正在尝试查询用户并使用 appsync 客户端:
const client = new AWSAppSyncClient({
url: awsconfig.aws_appsync_graphqlEndpoint,
region: awsconfig.aws_appsync_region,
auth: {
type: awsconfig.aws_appsync_authenticationType,
jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken()
},
complexObjectsCredentials: () => Auth.currentCredentials()
});
我已经能够使用放大网站上提供的示例成功运行突变
const result = await client.mutate({
mutation: gql(createTodo),
variables: {
input: {
name: 'Use AppSync',
description: 'Realtime and Offline',
}
}
});
但是在使用客户端运行查询时,他们提供的唯一示例是列表操作
const result = await client.query({
query: gql(listTodos)
});
他们没有提供如何通过特定 ID 进行查询的示例,所以我想知道是否有人可以对此语法有所了解,提供示例,或者为我指明一个好的参考方向为了这?提前谢谢你。
【问题讨论】:
标签: graphql aws-amplify aws-appsync