首页 > 解决方案 > graphql_flutter return LazyCacheMap,built_value deserializeWith JSON String,如何让它们协同工作

问题描述

graphql_flutterreturn LazyCacheMap, built_value deserializeWith JSON String, 如何让它们一起工作。

  1. graphql_flutter用来获取数据,响应将结果数据作为LazyCacheMap.
  2. built_value用于数据模型和数据序列化,但由于deserializeWith使用JSON String.

与他们一起工作的最佳方式是什么?

标签: fluttergraphql

解决方案


首先是对使用包encode的响应,然后执行您想要的任何操作。LazyCacheMapJSONdart:convert

import 'dart:convert';

GraphQLClient _client = graphQLConfiguration.clientToQuery();
QueryResult result = await _client.query(
  QueryOptions(
    documentNode: gql(GraphQlQueries.authenticateUser()),
  )
);

print(jsonEncode(result.data));

为我工作。


推荐阅读