Gatsby: [gatsby-source-contentful]: publicURL is missing from localFile when using the downloadLocal option

Created on 3 Dec 2019  路  5Comments  路  Source: gatsbyjs/gatsby

Description

When using the downloadLocal option with the Contentful plugin, publicURL is missing from localFile.

When checking GraphiQL, I see absolutePath which points to the cache folder (as mentioned in the docs) along with a whole lot of other fields, and I can query childImageSharp which returns a valid url, but publicURL is nowhere to be found.

Steps to reproduce

https://github.com/sebpettersson/gatsby-contentful-bug

Clone this, install dependencies, run gatsby develop, open http://localhost:8000/___graphql`.

See that publicURL is missing under contentfulGatsbyTest > imageField > localFile

NOTE: While setting up this test case, I noticed that sometimes the whole localFile field was missing - reinstalling the dependencies fixed this _some of the time_ (deleting .cache did not). Maybe that's another bug, or maybe it's related to the above.

Expected result

publicURL should point to an image file on the local file system.

Actual result

publicURL is missing.

Environment

System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/opt/node@10/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/opt/node@10/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 78.0.3904.108
Firefox: 70.0
Safari: 13.0
npmPackages:
gatsby: ^2.18.4 => 2.18.6
gatsby-source-contentful: ^2.1.66 => 2.1.66
npmGlobalPackages:
gatsby-cli: 2.8.14

Most helpful comment

Thanks, that worked!

Maybe the docs should be updated with that info?

gatsby-source-filesystem is mentioned there, but it isn't at all clear that an extra plugin is needed to access publicURL. Especially since ./cache/gatsby-source-filesystem/ exists even without that plugin.

All 5 comments

I replicated this locally and confirmed that publicUrl is not available on localFile even with downloadLocal: true in config.

I ran into the same problem

"gatsby": "^2.18.6", "gatsby-plugin-react-helmet": "^3.1.16", "gatsby-plugin-robots-txt": "^1.5.0", "gatsby-source-contentful": "^2.1.66", "react": "^16.12.0", "react-dom": "^16.12.0", "react-helmet": "^5.2.1"

Thank you for opening this!

You need to install gatsby-source-filesystem. See: https://github.com/gatsbyjs/gatsby/issues/4993

We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

Thanks, that worked!

Maybe the docs should be updated with that info?

gatsby-source-filesystem is mentioned there, but it isn't at all clear that an extra plugin is needed to access publicURL. Especially since ./cache/gatsby-source-filesystem/ exists even without that plugin.

Here's a plugin with just the copying logic from gatsby-source-filesystem
https://www.gatsbyjs.org/packages/gatsby-transformer-remote-filesystem/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

ferMartz picture ferMartz  路  3Comments

timbrandin picture timbrandin  路  3Comments

signalwerk picture signalwerk  路  3Comments