【发布时间】:2021-12-01 05:11:45
【问题描述】:
我是第一次测试flutter graphql。这是我正在使用 graphql explorer 的查询和变量。
我的问题是在我传递查询和queryVariables之前,我需要将queryVariables中的1001替换为参数值。我可以知道如何替换它吗?
const String query = r'''
query Albums($where: AlbumWhereInput) {
albums(where: $where) {
id
title
artist {
name
}
}
}
''';
const String queryVariables = r'''
{
"where": {
"artist_id": 1001
}
}
''';
Future<QueryResult> performQuery(String query,
{required Map<String, dynamic> variables}) async {
QueryOptions options =
QueryOptions(document: gql(query), variables: variables);
final result = await _client.query(options);
return result;
}
【问题讨论】: