【发布时间】:2016-08-25 04:50:21
【问题描述】:
不知道我在这里做错了什么。我的中继查询似乎组成正确(即我可以验证查询是否成功返回预期的结果)但是当应用程序在浏览器中呈现时我收到Error: repeat() argument must be greater than or equal to 0 and not be infinity 的错误。
应用程序一直很好,直到我添加了分页结果的片段 (edge + node):
const ConversationContainer = Relay.createContainer(Conversation, {
fragments: {
conversation: () => Relay.QL`fragment on Conversation {
id
fingerprint
unreadCount
messages(first: 3) {
pageInfo {
hasNextPage
}
edges {
node {
body
},
cursor
},
}
}`
}
})
和演示组件:
class Conversation extends Component {
render() {
const { id, fingerprint, unreadCount, messages } = this.props.conversation;
return <div>
<div>conversation <code>{id}</code></div>
<div>fingerprint: <code>{fingerprint}</code>, unreadCount: {unreadCount}</div>
<pre>{JSON.stringify(messages, null, 2)}</pre>
</div>;
}
}
那么错误的原因是什么?
编辑:错误出现在 UI 中,由我的根组件的 renderFailure 属性呈现(也作为控制台中的警告)
const root = <Relay.RootContainer
Component={AppContainer}
route={new AppRoute()}
renderLoading={() => <div>Loading...</div>}
renderFailure={(error, retry) => <div>Error: {error.message}</div>}
/>;
【问题讨论】:
-
中继片段对我来说看起来不错。问题可能与字符串有关:github.com/WebKit/webkit/commit/… 可能是打印
messages的元素一个一个会揭示一些东西。