Gatsby: Gatsby's data layer question

Created on 18 Dec 2017  路  2Comments  路  Source: gatsbyjs/gatsby

Gatsby's data layer is sort of magical.

It detects if a particular string is actually a path to file and also if the file is an image.
It then allows us to query on that image.

This hit me, while I was working with the YAML plugin, but then realised it happens with markdown and possibly with JSON as well?

I checked the source of the YAML plugin and did not find anything in there doing this, so this seems to be baked at a level deeper.

Can someone throw some light on how does this work?

question or discussion

Most helpful comment

This is done in gatsby core - if value looks like path gatsby will try to convert it to File node -
if you want to check you can start here: https://github.com/gatsbyjs/gatsby/blob/dcfa0fab32e168c075c052dde7ecd97736c6147a/packages/gatsby/src/schema/infer-graphql-type.js#L383

Other example of this is transforming string to dates (to allow date formatting in graphql etc)

All 2 comments

This is done in gatsby core - if value looks like path gatsby will try to convert it to File node -
if you want to check you can start here: https://github.com/gatsbyjs/gatsby/blob/dcfa0fab32e168c075c052dde7ecd97736c6147a/packages/gatsby/src/schema/infer-graphql-type.js#L383

Other example of this is transforming string to dates (to allow date formatting in graphql etc)

Thank you, this is a great starting point for me to dig deeper.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments

signalwerk picture signalwerk  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

andykais picture andykais  路  3Comments