2017-05-29 6 views
0

我试图做一个RANGE_ADD突变使用现在称为继电器经典(这可能是现代解决)。我得到的错误:突变没有请求在fatQuery上积极提取的容器数据RANGE_ADD

Warning: writeRelayUpdatePayload(): Expected response payload to include the newly created edge `newThingEdge` and its `node` field. Did you forget to update the `RANGE_ADD` mutation config?

所以,是的,有效载荷不发送任何的比预期的响应形状clientMutationId更因为请求突变不是自讨苦吃。

根据@Joe Savona在这里,https://github.com/facebook/relay/issues/521,如果没有相交的容器请求这个数据,这可能会发生。但这对我来说并不完全正确。我Route请求:

things: (Component) => Relay.QL` 
    query { 
     allThings(variable: $variable) { 
     ${Component.getFragment('things')}, 
     } 
    } 
`, 

,而我fatQuery正在请求:

fragment on AddMockThing { 
    allThings(variable: "${variable}", first: 100) { 
    edges { 
     node { 
     id, 
     }, 
    }, 
    }, 
    newThingEdge 
} 

现在你可能会说这是不一样的疑问,因为在getFatQuery版的额外first: 100,但如果我不使用,我得到的错误:

Error: Error: You supplied the 'edges' field on a connection named 'allThings', but you did not supply an argument necessary to do so. Use either the 'find', 'first', or 'last' argument.

在另一方面,如果我的广告d first: 100Route查询,我得到的错误:Error: Invalid root field 'allThings'; Relay only supports root fields with zero or one argument.

卡住fatQuery和困难的地方之间。将不胜感激的帮助!

回答

0

由于中继编译器正在查找连接参数(first: X),您将收到验证错误。您可以通过添加@relay(pattern: true)指令来禁用此特定验证。这标志着胖查询是一种“模式”来匹配,而不是具体的事情。

fragment on AddMockThing @relay(pattern: true) { 
    allThings(variable: "${variable}") { 
    edges { 
     node { 
     id, 
     }, 
    }, 
    }, 
    newThingEdge 
} 

此处了解详情:https://stackoverflow.com/a/34112045/802047

+0

感谢@steveluscher!在回到代码中使用您的建议(并替换我的解决方法)之前,我们只需要现在就承认它。 –