birkir / gatsby-source-prismic-graphql

Gatsby source plugin for Prismic GraphQL
MIT License
137 stars 75 forks source link

fix: unescape createRemoteFileNode url #143

Closed bwlt closed 4 years ago

bwlt commented 4 years ago

Prismic returns "percent-encoding" image urls, files were saved by Gatsby but could not be used.

Example

Before the fix:

"image": {
  "url": "https://.../repo-name%2F3ccbf3d2-e178-4ad5-be80-52fb5324c220_mission-headline.svg"
},
"imageSharp": {
  "publicURL": "/static/repo-name%2F3ccbf3d2-e178-4ad5-be80-52fb5324c220_mission-headline.svg"
}

With the fix:

"image": {
  "url": "https://.../repo-name%2F3ccbf3d2-e178-4ad5-be80-52fb5324c220_mission-headline.svg"
},
"imageSharp": {
  "publicURL": "/static/3ccbf3d2-e178-4ad5-be80-52fb5324c220_mission-headline-231ee29b25c7112da6767fe575dcc09e.svg"
}
bwlt commented 4 years ago

Retriggered the build. check this

sebastiansson commented 4 years ago

This is causing a new error for us. @bwlt Can you explain why this is needed? I had no issues with using images with Gatsby before this PR.

We seem to only get this error with images with UTF-8 characters like the swedish 'åäö'. We get this error:


ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unexpected error value: "wrong url: https://images.prismic.io/{reponame}/ed3d852f-cf8b-4a36-9a04-ae7d18524e44_LindaÅkerberg_SUP.jpg?auto=compress,format"

   92 |     }
   93 |   }
   94 | }
   95 |
   96 | fragment ImageFragment on PRISMIC_ContentBodyImage {
   97 |   type
   98 |   primary {
   99 |     image_variant
  100 |     image_caption
  101 |     image_image
> 102 |     image_imageSharp {
      |     ^
  103 |       childImageSharp {
  104 |         fluid(maxWidth: 1900) {
  105 |           ...GatsbyImageSharpFluid
  106 |         }
  107 |       }
  108 |     }
  109 |   }
  110 | }
  111 |
  112 | fragment FeatureFragment on PRISMIC_ContentBodyFeature {

File path: /../src/templates/content.js
Url path: /da/...
Plugin: none```
bwlt commented 4 years ago

@sebastiansson didn't inspected much on this 😅 The build failed to me, so in my company we were relying on the previous PR https://github.com/birkir/gatsby-source-prismic-graphql/pull/89 (this PR is simply a port of #89 ). Maybe @rdanchev have more information on this

sebastiansson commented 4 years ago

@bwlt Thanks for the response. Would be great if @rdanchev or @adnsio could explain this more. Really hard to follow what's happening here.

n00b2pr0 commented 4 years ago

Impacted by this change as well on 3.5.0. Here's what I'm experiencing.

Error when running Gatsby, similar to @sebastiansson :

Unexpected error value: "failed to process https://images.prismic.io/{my repo name}/{my image name}.jpg?auto=compress,format
\nError: ENOENT: no such file or directory, open '{my project path}/.cache/caches/gatsby-source-prismic-graphql/tmp-c6ab15163d8b1a70ade6b1229b8b21bb.jpg'"

It looks like images aren't getting saved to cache in .cache/caches/gatsby-source-prismic-graphql.