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

Frontmatter list items not treated as Files #2687

Closed
dustinhorton opened this issue Oct 31, 2017 · 9 comments
Closed

Frontmatter list items not treated as Files #2687

dustinhorton opened this issue Oct 31, 2017 · 9 comments

Comments

@dustinhorton
Copy link
Contributor

(Originally raised @ #780 (comment), but think it may have been missed, so wanted to make a fresh issue).

Using 1.9.83:

Markdown frontmatter list:

images:
  - ./images/01.jpg
  - ./images/02.jpg
  - ./images/03.jpg

Query:

{
  markdownRemark {
    frontmatter {
      images
    }
  }
}

Result:

{
  "data": {
    "markdownRemark": {
      "frontmatter": {
        "images": [
          "./images/01.jpg",
          "./images/02.jpg",
          "./images/03.jpg"
        ]
      }
    }
  }
}

And if trying to treat as Files:

{
  markdownRemark {
    frontmatter {
      images {
        childImageSharp {
          responsiveSizes {
            src
          }
        }
      }
    }
  }
}

Result:

{
  "errors": [
    {
      "message": "Field \"images\" must not have a selection since type \"[String]\" has no subfields.",
      "locations": [
        {
          "line": 4,
          "column": 14
        }
      ]
    }
  ]
}
@KyleAMathews
Copy link
Contributor

Can you build a reproduction site? There's been several PRs addressing this recently so not sure what's wrong.

@dustinhorton
Copy link
Contributor Author

@KyleAMathews Give this a shot: https://github.com/dustinhorton/gatsby-issue

It's the blog starter, and I've modified the 'New Beginnings'/'/hi-folks/' post. Not sure that was an optimal repro…let me know if I can provide something better.

@KyleAMathews
Copy link
Contributor

The images have to exist for the link to be created.

@dustinhorton
Copy link
Contributor Author

dustinhorton commented Oct 31, 2017

@KyleAMathews Apologies, I'd forgotten to git add after adding them to the repro site. I've added them: https://github.com/dustinhorton/gatsby-issue/commit/fddf025b84c1889f2afdfa92c51ff9419e3c77f3

@KyleAMathews KyleAMathews reopened this Oct 31, 2017
@KyleAMathews
Copy link
Contributor

Ok, found the source of the bug. For our GraphQL inference, we have a general type inference and then we do special mappings for manual mappings, the ___NODE syntax, and file mappings. We're not looking inside arrays right now for file mappings. I'll put together a quick PR for that.

Thanks @dustinhorton for the repo site! Always super helpful to have those when debugging.

@owenhoskins
Copy link
Contributor

Hello @KyleAMathews, I was wondering if this addresses a nested list within a list?

I am getting this error GraphQL Error Field "image" must not have a selection since type "String" has no subfields. with this in my frontmatter:

portfolios:
  - images:
      - image: /img/image1.jpg
  - images:
      - image: /img/image2.jpg

Images within a top-level list behave as expected. Could this be related?

@KyleAMathews
Copy link
Contributor

@owenhoskins try not repeating your keys (you have two images) and see if it starts working?

@owenhoskins
Copy link
Contributor

@KyleAMathews Thanks for the reply. It turns out the repeating keys were not the issue! Rather I had a onCreateNode API function that was throwing off the file system.

@justinlevi
Copy link

I recently had an odd issue with the Type inference not working with what seemed like some reserved keys. I had a header key with an image path that the auto-inference didn't seem to like.

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

4 participants