有没有办法通过反应道具传递阿波罗查询选择?

Is there a way to pass an Apollo query selection through react props?

响应 Apollo 调用填充数据属性的方式

   graphql(withQLTag)(ReactComponent) 

存在于组件 class 之外。

但是,如果我想通过预定义查询通过 react prop 控制我使用哪些数据,以便我可以为多个数据模型重用一个列表怎么办?(我知道列表视图必须从中存在的属性中提取所有数据返回)

   render() {
       return(
          <ReactComponent qlTag="Model1">
       )...

有办法解决这个问题吗?

您可以制作任意数量的包装组件:

import MyListComponent from './somewhere';

const ProductListComponent = graphql(ProductListQuery)(MyListComponent) 
const EventListComponent = graphql(EventListQuery)(MyListComponent) 
const SomethingElseListComponent = graphql(SomethingElseListQuery)(MyListComponent) 

graphql 包装器想象成只是创建一个传递一些道具的组件。