Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple queries under a single root query not passing all data to props #1459

Closed
Bouncey opened this issue Jul 10, 2017 · 4 comments
Closed

Comments

@Bouncey
Copy link
Contributor

Bouncey commented Jul 10, 2017

This is my query in Article.jsx which is a template component

export const pageQuery = graphql`
query ArticleBySlug($slug: String!) {
  markdownRemark(fields: { slug: { eq: $slug }}) {
    html
    frontmatter {
      title
    }
  }
  # get all site pages to pass to parent to render nav
  allMarkdownRemark {
    edges {
      node {
        frontmatter {
          title
          parent
        }
      }
    }
  }
}
`;

I only get markdownRemark in this.props.data and not allMarkdownRemark

Am I missing something?

I there an easier way to get what I am after in my Layout.jsx?

@Bouncey
Copy link
Contributor Author

Bouncey commented Jul 11, 2017

To solve this, I have taken to creating a JSON object which I import into my layout component.

@KyleAMathews
Copy link
Contributor

This should work. Does the query work in graphiql?

@KyleAMathews
Copy link
Contributor

Wait layout? Graphql queries aren't yet supported in layout queries.

@Bouncey
Copy link
Contributor Author

Bouncey commented Jul 11, 2017

Yes the query works in graphiql. I found an issue relating to queries in layout, so I tried a dual query in my article template with a view of passing the data up to my layout component. I don't think that changing queries is triggering a cache bust, as seen in other scenarios.

I understand now that this would be too much of an overhead as it would attach the allMarkdownRemark data to every single page. Which with over 700 pages just isn't workable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants