我很难理解 WrapQuery
构造函数的参数。根据文档,签名为:
WrapQuery( path: Array<string>, wrapper: QueryWrapper, extractor: (result: any) => any, )
对于QueryWrapper
,我进行了深入研究,并在代码中找到了此声明(文档中没有内容):
export declare type QueryWrapper = (subtree: SelectionSetNode) => SelectionNode | SelectionSetNode;
我有一个突变,并且我想将此突变的输入变量转换为其他输入变量。到目前为止,我什至都没有管理他们在文档中得到的示例https://www.apollographql.com/docs/graphql-tools/schema-transforms:
new WrapQuery(
['priv_createConsumer'],
(subtree) => { // subtree seems to contain one node only?? weird
return {
kind: Kind.FIELD, // no idea which enum should I use here
name: {
kind: Kind.NAME, // no idea which enum should I use here
value: 'contact',
},
selectionSet: subtree,
}
},
// how to process the data result at path
(result) => { // result is mostly undefined or null (based on few things I tried to change
return result && result.address
}
)