Hi, what's missing?
My title is undefined...



Found the solution but don't understand why.
I had to "merge" both query instead doing two export const query.
Now my metadata is displayed inside props.data.
Someone can explain why please?
export const pageQuery = graphql`
query HomeQuery {
allContentfulBlogPost(
filter: {
node_locale: {
eq: "fr"
}
}
sort: {
fields: [publishDate], order: DESC
}
) {
edges {
node {
node_locale
title
slug
publishDate(formatString: "MMMM Do, YYYY")
tags
heroImage {
sizes(maxWidth: 350, maxHeight: 196, resizingBehavior: SCALE) {
...GatsbyContentfulSizes_withWebp
}
}
description {
childMarkdownRemark {
html
}
}
}
}
}
}
`
export const mainQuery = graphql`
query MainQuery {
site {
siteMetadata {
title
}
}
}
`
export const pageQuery = graphql`
query HomeQuery {
allContentfulBlogPost(
filter: {
node_locale: {
eq: "fr"
}
}
sort: {
fields: [publishDate], order: DESC
}
) {
edges {
node {
node_locale
title
slug
publishDate(formatString: "MMMM Do, YYYY")
tags
heroImage {
sizes(maxWidth: 350, maxHeight: 196, resizingBehavior: SCALE) {
...GatsbyContentfulSizes_withWebp
}
}
description {
childMarkdownRemark {
html
}
}
}
}
}
site {
siteMetadata {
title
}
}
}
`
you can only have one pagequery. and you should put all your queries in there. why would you need to define two?
you can only have one pagequery. and you should put all your queries in there. why would you need to define two?
Yeah I don't even know why I wanted to do this.
Just one last question.
So I can only have one main query by pages.
Whatever if I have multiples query Contentful, Markdown, json etc..., I have to merge them in one query and Gatbsy do the job?
Yes, if you have different sources and want to have them in one query you can do this:
query NamedQuery {
posts: allMarkdownRemark {
edges {
node {
id
}
}
}
categories: allSomethingElse {
edges {
node {
id
}
}
}
}
const myPosts = result.data.posts.edges
const myCategories = result.data.categories.edges
Thank you all!