简体   繁体   English

graphql_flutter 返回 LazyCacheMap,built_value deserializeWith JSON String,如何让它们协同工作

[英]graphql_flutter return LazyCacheMap, built_value deserializeWith JSON String, how to make them work together

graphql_flutter return LazyCacheMap , built_value deserializeWith JSON String , how to make them work together. graphql_flutter回报LazyCacheMapbuilt_value deserializeWith JSON String ,如何让他们一起工作。

  1. I use graphql_flutter to fetch data, and response give the result data as LazyCacheMap .我使用graphql_flutter来获取数据,然后响应将结果数据作为LazyCacheMap
  2. And using built_value for data model & data serialization, but since deserializeWith working with JSON String .并使用built_value的数据模型和数据序列化,但由于deserializeWith有工作JSON String

What's the best way to work with them together ?与他们一起工作的最佳方式是什么?

  • Should I just convert LazyCacheMap 's data of to String and call deserializeWith ?如果我只是转换LazyCacheMap的的数据String并调用deserializeWith
  • should I use other serialization pubs ?我应该使用其他序列化酒吧吗?

First encode the response LazyCacheMap to JSON using the dart:convert package, then perform whatever operation you want.首先使用dart:convert包将响应LazyCacheMap encodeJSON ,然后执行您想要的任何操作。

import 'dart:convert';

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

print(jsonEncode(result.data));

Worked for me.为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 graphql_flutter 中重试对 GraphQLError 的请求 - How to retry a request on GraphQLError in graphql_flutter 如何用 Map 进行序列化<string, dynamic>使用 package built_value</string,> - How to serialize with Map<String, dynamic> using the package built_value Flutter:在包built_value 中随机播放BuiltList - Flutter: Shuffle BuiltList in Package built_value graphql_flutter 突变查询需要返回语句 - 不确定如何添加它 - graphql_flutter mutation query expects return statement - not sure how to add it 在 dart/flutter 和 built_value 中编码为标准的、冒号分隔的 json - Encoding to a standard, colon-seperated json in dart/flutter and built_value Dart的built_value库,如何在flutter中生成序列化文件? - Dart's built_value library, how to generate the serializer file in flutter? Flutter - SEMBAST与built_value的集成,如何将Model插入到sembast db - Flutter -integration of SEMBAST with built_value , how to insert the Model into the sembast db 在flutter中使用built_value创建不可变模型时出错 - Error while creating immutable model using built_value in flutter built_value与flutter_test有依赖项冲突 - built_value has a dependency conflict with flutter_test 如何在dart中的built_value序列化中将Date ISO String反序列化为DateTime Object? - How to deserialize Date ISO String to DateTime Object in built_value serialization in dart?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM