我正在构建一个颤振应用程序并使用 amplify_flutter0.2.1
和 amplify v ,当我从 Amplify-admin UI 中提取项目时,它会生成一个在前端无用5.1.0
的 graphQL 模式,因为每次我们需要时都需要获取或修改文档schema.graphql
像这样编写graphQL查询文档:
String graphQLDocument =
'''mutation CreateTodo(\$name: String!, \$description: String) {
createTodo(input: {name: \$name, description: \$description}) {
id
name
description
}
}''';
var operation = Amplify.API.mutate(
request: GraphQLRequest<String>(document: graphQLDocument, variables: {
'name': 'my first todo',
'description': 'todo description',
}));
我想这样写:
const input = {
name,
description
};
const output = {
id,name,description
};
var graphQLDoc = createToDO(input,output); // it should return the string object according to the input and output passed.
var operation = Amplify.API.mutate(
request: GraphQLRequest<String>(document: graphQLDoc, variables: {
'name': 'my first todo',
'description': 'todo description',
}));
或者它可以像这样先进:
const input = {
name:"hackrx",
description: "this works cool"
};
const output = {
id,name,description
};
var graphQLQueryRes = await createToDO(input,output); // it should return the whole fetched object according to the output passed.