gatsby-transformer-remark cannot handle an array of objects

Created on 11 May 2018  Â·  6Comments  Â·  Source: gatsbyjs/gatsby

Description

The frontmatter cannot handle an array of objects, and seems to call toString() on the object somewhere

Steps to reproduce

add a frontmatter like this

authors:
  - name: foo
    avatar: ../../path
    page: /path/to/page
  - name: bar
    avatar: ../../path2
    page: /path/to/page

and print it to the console to see this


authors:Array(2)
  0:"[object Object]"
  1:"[object Object]"

Expected result

I would expect to see my array of objects in the frontmatter

Actual result

I get the string representation of the object

Environment

  • Gatsby version (npm list gatsby): 1.9.250
  • gatsby-cli version (gatsby --version): 1.9.260
  • Node.js version: 10.1.0
  • Operating System: OSSierra 10.13.4

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

question or discussion

Most helpful comment

If you starter develop when you had array of string in author field gatsby would create schema as array of strings and changing those strings to objects while develop is running won't cause schema to update (Gatsby just doesn't update schema while it's running). I will be looking to add schema updates in future.

All 6 comments

Where are you printing to the console?

I am printing to the console in the render method of the page/component
that queries the front matter.

Someone in discord mentioned that they think it might be due to not quoting
the strings in the front matter but I haven't had a chance to try it out yet

On Fri, 11 May 2018, 3:28 pm Kyle Mathews, notifications@github.com wrote:

Where are you printing to the console?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/5372#issuecomment-388273311,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_NQAnbFurOm5_7WDS_mLm_h-CKf3O6ks5txS-jgaJpZM4T67Iq
.

I'm not seeing this when trying to reproduce :/

hmm yes you are right, I am not sure what was causing the string representation, but a server restart seemed to fix it. Sorry my mistake

If you starter develop when you had array of string in author field gatsby would create schema as array of strings and changing those strings to objects while develop is running won't cause schema to update (Gatsby just doesn't update schema while it's running). I will be looking to add schema updates in future.

ahh that is indeed what happened

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikestopcontinues picture mikestopcontinues  Â·  3Comments

timbrandin picture timbrandin  Â·  3Comments

kalinchernev picture kalinchernev  Â·  3Comments

andykais picture andykais  Â·  3Comments

brandonmp picture brandonmp  Â·  3Comments