I'm new to GraphQL and Relay and I'm struggling with queries, fragments, ...spreads & passing props. I think I'm unnecessarily passing props down through many, many components. I want to learn how to teleport my data objects from the QueryRenderer to deeply nested components, skipping all the ancestor components.
Suppose I have a component structure like this. I need a list of emojis from the 'emoji' table inside EmojisList
component which is deep in the app. I'm not sure where to spread or pass props or when to ask for the actual scalars.
<MainApp>
<QueryRenderer
environment={environment}
query={graphql`
query MainAppQuery {
currentPerson { // current user
...Timeline_currentPerson
}
allEmojis {
...ReactionBar_emojisList
}
}
`}
/>
<Timeline currentPerson={props.currentPerson}>
<PostList>
<Post>
<ReactionBar>
<EmojisList>
// I need this list
export default createFragmentContainer(ReactionBar, {
emojisList: graphql`
fragment ReactionBar_emojisList on EmojisConnection @relay(plural: true) {
edges {
node {
name
rowId
}
}
}
`,
});
</EmojisList>
</ReactionBar>
</Post>
</PostList>
</Timeline>
</MainApp>