Gatsby: Gatsby query for multiple ids

Created on 23 Oct 2018  路  2Comments  路  Source: gatsbyjs/gatsby

My requirement is to fetch data for particular ids only. Graphql query is following

query pageQuery {
    contentfulFeaturedContent(contentful_id:{in:["4IcVFLJ1EkCUAgQosWCmma", "2eUt6Ht7LOKsmigqC8qAYM"]}){
      heading
  }
} 

Issue is, it is returning only 1 data, the one which is added last in contentful. Please help

question or discussion

Most helpful comment

contentfulFeaturedContent will return always just 1 result - you'll want to use connection here:

allContentfulFeaturedContent(filter: { contentful_id:{in:["4IcVFLJ1EkCUAgQosWCmma", "2eUt6Ht7LOKsmigqC8qAYM"]}}) {
  edges {
    node {
      heading
    }
  }
}

All 2 comments

contentfulFeaturedContent will return always just 1 result - you'll want to use connection here:

allContentfulFeaturedContent(filter: { contentful_id:{in:["4IcVFLJ1EkCUAgQosWCmma", "2eUt6Ht7LOKsmigqC8qAYM"]}}) {
  edges {
    node {
      heading
    }
  }
}

This solved my issues. Thanks!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blainekasten picture blainekasten  路  130Comments

ehowey picture ehowey  路  97Comments

cutemachine picture cutemachine  路  112Comments

KyleAMathews picture KyleAMathews  路  97Comments

cusspvz picture cusspvz  路  128Comments