使用Amplify自定义GraphQL查询时无法获取nextToken求助
Amplify Android GraphQL分页与序列化问题
// MovieList 函数定义 private fun getMovieList(): GraphQLRequest<MovieDBFinal2> { val document = ("query getMovieList { " + "listMovieDBFinal2s(limit: 1000, filter: {Genre1: {eq: \"Animation\"}}) { " + "nextToken " + "items { " + "IMDB_title " + "} " + "} " + "} ") return SimpleGraphQLRequest( document, Collections.emptyMap(), TypeMaker.getParameterizedType(QueryResponse::class.java, MovieDBFinal2::class.java), GsonVariablesSerializer()) } internal class QueryResponse<T> { private val listMovieDBFinal2s: QueryList<T>? = null val moviesList: QueryList<T>? get() = listMovieDBFinal2s } internal class QueryList<T> { val items: Iterable<T>? = null val nextToken: String? = null } // MovieList 函数调用 Amplify.API.query( getMovieList(), { response -> if (response.hasData()) { Log.e("MovieList", "$response") } }, { failure -> Log.e("MovieList", "Query failed.", failure) } )
- 在Schema中使用自定义类型无效
- PaginationResult无法正常工作,Iterable无法返回nextToken
- 仅能以
String.class类型完成请求,但后续序列化难度大 - 当前临时解决方案:发起两次相同请求,一次传入nextToken使用PaginationResult,另一次使用
String.class类型
内容的提问来源于stack exchange,提问作者the coder
相关产品推荐
相关产品推荐

