简体   繁体   中英

GatsbyJS - How to query longtext Contentful fields in GraphQL

I ran into a problem querying a field of type "long text" from contentful.

I know the Contentful long text field is actually markdown. So I installed the gatsby-transformer-remark plugin, which I presumed I need.

Here's my GraphQL query:

  query getStoreById($relativeUrl: String!) {
    contentfulStore(relativeUrl: { eq: $relativeUrl }) {
      relativeUrl
      shopPageTitle
      mainPageTextContent {
        mainPageTextContent
      }
    }
  }

The console still shows:

Objects are not valid as a React child (found: object with keys {childMarkdownRemark}). 

Something to do with that error message.

Thanks!

The query will look something like:

query getStoreById($relativeUrl: String!) { contentfulStore(relativeUrl: { eq: $relativeUrl }) { relativeUrl shopPageTitle mainPageTextContent { childMarkdownRemark { html } } } }

If you haven't learned how to use Graph i QL yet, try opening it at localhost:8000/___graphql! It's your best friend for learning how to query your Contentful schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM