docs describe rangeBehaviors
为:
GraphQL的映射调用我们希望Relay在这些调用的影响下向连接添加新边时所展示的行为。行为可以是'追加',' prepend'或'删除'。
文档中的示例是:
rangeBehaviors: {
// When the ships connection is not under the influence
// of any call, append the ship to the end of the connection
'': 'append',
// Prepend the ship, wherever the connection is sorted by age
'orderby(newest)': 'prepend',
}
以及todos example repo中的另一个例子:
rangeBehaviors: {
'': 'append',
'status(any)': 'append',
'status(active)': 'append',
'status(completed)': null,
}
什么是" GraphQL调用"在这种情况下? "在"的影响下是什么意思?这样的电话?
答案 0 :(得分:2)
当您在中继中查询连接字段时,您可以指定除first
,last
,before
和after
的标准分页参数之外的参数。
在上面的TodoMVC示例中,我们通过当前过滤器对状态进行限定。您已经显示的TodoMVC代码的含义是,突变应该为筛选"active"
或"any"
(或默认状态)状态的查询附加新todo,但不会查询只过滤到"completed"
的状态(这在上下文中是有意义的,因为变异会添加一个新的,活跃的待办事项)。