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?
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.
Most helpful comment
This is done in gatsby core - if value looks like path gatsby will try to convert it to
Filenode -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)