我有一个组件,需要查询两个完全独立的表。在这种情况下,模式、查询和解析器需要什么样的外观?我已经搜索过,但还没有找到例子。谢谢您提供任何信息。
更新:我发现可能有一种方法可以将compose用于此目的,例如:
export default compose(
graphql(query1,
....),
graphql(query2,
....),
graphql(query3,
....),
withApollo
)(PrintListEditPage)是否有一种方法可以具有以下多个声明:
const withMutations = graphql(updateName, {
props({ mutate }) {
return {
updatePrintListName({ printListId, name }) {
return mutate({
variables: { printListId, name },
});
},
};
},
});...that在调用export default compose之前就来了
发布于 2016-10-30 12:29:12
graphql函数采用可选的第二个参数,允许您将传递的属性名化名为别名。如果有多个突变,可以使用name属性根据需要重命名mutate:
import { graphql, compose } from 'react-apollo'
export default compose(
graphql(mutation1, { name: 'createSomething' }),
graphql(mutation2, { name: 'deleteSomething' }),
)(Component)有关更多细节,请参见完整API。
https://stackoverflow.com/questions/40324512
复制相似问题