我正在按照文档(https://aws-amplify.github.io/docs/js/api#amplify-graphql-client)进行查询,但我一直收到以下错误:
TypeError: Must provide Source. Received: undefined
Run Code Online (Sandbox Code Playgroud)
查询如下:
export const listUsers = `query ListUsers(
$filter: ModelUserFilterInput
$limit: Int
$nextToken: String
) {
listUsers(filter: $filter, limit: $limit, nextToken: $nextToken) {
items {
id
firstName
prefix
lastName
phone
cigarettesDay
enableNotifications
age
coach {
id
name
}
stopDate {
nextToken
}
notifications {
nextToken
}
}
nextToken
}
}
`;
Run Code Online (Sandbox Code Playgroud)
使用API.graphqlI 调用查询如下:
async componentDidMount() {
try {
const result = await API.graphql(graphqlOperation(listUsers));
console.log(result);
} catch (err) {
console.log(err);
} …Run Code Online (Sandbox Code Playgroud)