Similar when we're using ${Component.getFragment('fragment')}
, is there a way I can simply concat a variable with a valid query inside a relay fragment? similiar to this:
const query = `
allFriends {
id
}
`
Relay.createContainer(Component, {
fragments: {
viewer: () => Relay.QL`
fragment on Query {
allUsers {
id
}
${query}
}
`
}
});
Thanks!
答案 0 :(得分:1)
RelayQL插件允许您通过将片段定义为变量来实现此目的。 RelayQL文档页面上的See example here或参见下面的示例:
在这里,我在电子邮件类型上创建了一个片段,我可以将该片段注入电子邮件类型的任何字段,例如面试#email或User#email:
defp stream_from_file(fpath, bytes) do
File.stream!(fpath, [], bytes)
|> Enum.each(fn chunk ->
PubSub.publish(:topic1, {:topic1_data, chunk})
:timer.sleep(1_000)
end)
stream_from_file(fpath, bytes)
end