[英]Adding multiple variables in GraphQL library for dart [flutter]
我一直在使用這種依賴https://pub.dev/packages/graphql來嘗試在我的應用程序中使用 graphql 並且它可以工作,但是當我需要將多個字段傳遞給variables
參數時,例如variables: {'cursor': fetchMoreCursor}, {'boney': MamboBattle}
我收到錯誤_CastError (type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast)
我不知道如何添加不止一個領域,有沒有人知道或者我僅限於使用一個?
完整代碼:
static final AuthLink _authLink = AuthLink(
getToken: () async => 'Bearer $tokenGG',
);
static final Link _link = _authLink.concat(_httpLink);
final GraphQLClient _client = GraphQLClient(
cache: InMemoryCache(),
link: _link,
);
Future<QueryResult> searchTournys(name, page) async {
final QueryOptions options = QueryOptions(
document: queryStrings(Query.searchTourneys, page),
variables: <String, dynamic>{ //<-*ERROR HERE*
'name': name,
'page': page
},
);
final QueryResult result = await _client.query(options);
return result;
}
您不應該有兩個不同的地圖,而只是在第一個地圖中添加更多條目: {'cursor': fetchMoreCursor, 'boney': MamboBattle}
如果它是一個突變,你可以像這樣使用它: runMutation({'cursor': fetchMoreCursor, 'boney': MamboBattle})
如果它是一個查詢(或者你也想在突變上使用它),你應該這樣做:(變量:{'cursor':fetchMoreCursor,'boney':MamboBattle})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.