Reputation: 97
I have a filtered query in GraphQL that return only some specific content , while I want to add this same query but to display all it content . I cannot use two similar queries in the same page , eventually I cannot pass this all data that I want , even if I add this query in a component it will cause an error of undefined . This is the query :
allPrismicCollection(
sort: {fields: data___collection___text, order: ASC}
limit: $limit
skip: $skip
) {
nodes {
data {
slides {
slide {
document {
... on PrismicSlide {
data {
blogs {
blog {
document {
... on PrismicBlog {
uid
data {
image {
gatsbyImageData(aspectRatio: 1.5)
}
}
}
}
}
}
}
}
}
}
}
}
}
}
and this is the query I want to add as well :
allPrismicCollection {
nodes {
data {
collection {
text
}
slides {
slide {
document {
... on PrismicSlide {
id
data {
blogs {
blog {
document {
... on PrismicBlog {
id
data {
tags {
tag
}
}
}
}
}
}
}
}
}
}
}
}
}
}
Any idea how to mix these queries , or maybe to add it independently in components ?! Thanks.
Upvotes: 1
Views: 105
Reputation: 29320
I cannot use two similar queries in the same page
You can as long as you alias them. Like:
result1: allPrismicCollection(
sort: {fields: data___collection___text, order: ASC}
limit: $limit
skip: $skip
) {
nodes {
data {
slides {
slide {
document {
... on PrismicSlide {
data {
blogs {
blog {
document {
... on PrismicBlog {
uid
data {
image {
gatsbyImageData(aspectRatio: 1.5)
}
}
}
}
}
}
}
}
}
}
}
}
}
}
result2: allPrismicCollection {
nodes {
data {
collection {
text
}
slides {
slide {
document {
... on PrismicSlide {
id
data {
blogs {
blog {
document {
... on PrismicBlog {
id
data {
tags {
tag
}
}
}
}
}
}
}
}
}
}
}
}
}
}
The result of each specific query, instead of being inside props.data.allPrismicCollection
will be inside of props.data.result1
and props.data.result2
respectively.
Upvotes: 1