我试图得到我们的图形的对象表示,而无需编写自定义的东西来解析 introspectionQuery
的输出 .
理想情况下,这将是一个JSON对象,其具有类型名称的键及其类型作为查询结果形状的值 .
我一直在玩 graphql/utilities
但是找不到办法做这件事 .
有什么想法吗?
像这样的东西:
import { graphql } from 'graphql';
import { introspectionQuery } from 'graphql/utilities';
import schema from '../schema';
export default async function(req, res) {
const result = await graphql(schema, introspectionQuery, {}, {}, {});
return res.json(result);
}
输出模式,但它不是我们数据的直观表示 .
1 回答
在这里找到我的答案:https://github.com/APIs-guru/graphql-voyager