使用 lodash 语法对 GraphQL 查询进行数据操作
在 GraphQL 查询中释放 lodash 的强大功能
yarn add graphql-lodash
graphqlLodash(query, [operationName]){
query: string|object,
transform: Function
}@_ 指令后的原始查询response.data 作为单个参数并返回的函数
以预期的形状显示相同的数据。将 graphql-lodash 集成的最简单方法是为您选择的 graphql 客户端编写封装函数:
import { graphqlLodash } from 'graphql-lodash';
function lodashQuery(queryWithLodash) {
let { query, transform } = graphqlLodash(queryWithLodash);
// 使用 'query' 变量作为查询进行 GraphQL 调用
// 并将结果放入 'result' 变量中
…
result.data = transf
[](https://david-dm.org/APIs-guru/graphql-lodash)暂无开放 Issues,或尚未同步最近议题。