I'm trying to get content relationship data in my slice.
I've read all the documents and managed to cobble together graphQuery to my page.tsx which seems to work and pass down to my slice component:
The issue I have is now all my other slices disappear, does that mean when wanting to add a few extra fields in 1 slice, I have to write out every field I want on my page in the grapqhquery?
Is there a better way of doing this? it seems silly having to write out every slice data, if there a way of adding graphquery to the individual slice itself?
Currently, it's not possible to use something like GraphQL Fragments to reuse fields across slices. However, a good approach is to let each slice manage its own graphQuery.
While this may require repeating a few lines of code, it keeps your main page component in order, with each slice only querying the data it needs.
So each Slice would have its own graphQuery in the component
What you're doing was good, you would just query it and then give the slice that queried data, and repeat it as needed. If we're misunderstanding the situation here though, feel free to correct me on what's happening and provide more details
If I add a graphquery on the page to get the content relationship for a specific slice, all other slice data disappears, i don't want to have to add all slice data to the graphquery.
@Pau suggested adding the graphquery to the slice itself, but I can't find an example of how to do this.
Apologies for the confusion. So you were right on your first post, you do have to write out every slice data to make them all appear in your slice. We know this is silly and inefficient, and we intend to have a better way to make this work in the future, unfortunately as of now this is the only way to get all of your slice data via graphquery. Apologies for the inconvenience (and the miscommunication on this post)!
Don't hesitate if I can help you with anything else
So just to confirm, there is no way just to have the graqhquery on the slice? It has ro go on the page(parent) and you have to pass it down to the slice? - at the same time you need to write out EVERY slice's data in the page graphquery?
Exactly, really sorry about that. Again we know it's far from ideal - we are working on improving it, so this isn't how it's going to stay in the future. For now though, that's the way you'd have to do it if you need to use GraphQuery.