Gatsby: [gatsby-transformer-json] Filter data by attribute

Created on 12 Oct 2017  ·  3Comments  ·  Source: gatsbyjs/gatsby

When using gatsby-transformer-json filtering an array doesn't work:

data.json

{
  "foo": [
    {
      "name": "Name 1"
    },
    {
      "name": "Name 2"
    }
  ]
}

graphQL

{
  dataJson(foo: {in: {name: {ne: "no match"}}}) {
    foo {
      name
    }
  }
}

error

{
  "errors": [
    {
      "message": "Cannot read property 'id' of undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "dataJson"
      ]
    }
  ],
  "data": {
    "dataJson": null
  }
}

It's the same if the data-array has an id-attribute in the object.

gatsby v1.9.45

Most helpful comment

Up!
Did you find a solution?

I'm having the same problem..

All 3 comments

Up!
Did you find a solution?

I'm having the same problem..

@MarbleCK nope. I didn't look into it anymore. Keep me posted if you find a solution.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues as many of them have already been resolved with the latest updates or explained in a previous issue.

Feel free to open a new one if you still experience this problem or a similar one! 👍

Also, marking this as a duplicate to #3643

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  ·  3Comments

mikestopcontinues picture mikestopcontinues  ·  3Comments

totsteps picture totsteps  ·  3Comments

Oppenheimer1 picture Oppenheimer1  ·  3Comments

ghost picture ghost  ·  3Comments