-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
GraphQL Error for empty string path when converting relative urls #14018
Comments
Hey, we need #13028 to fix this. After that you would be able to specify in your graphql schema that File should be resolved using relative path (right now type is correct, but fields are being resolved to strings with this empty image string in frontmatter). You can use it right now if you don't mind using pre-release version: diff --git a/package.json b/package.json
index f392eff..9b6e316 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"dependencies": {
"deep-map": "^2.0.0",
"es6-weak-map": "^2.0.2",
- "gatsby": "^2.4.3",
+ "gatsby": "schema-customization",
"gatsby-image": "^2.0.41",
"gatsby-plugin-offline": "^2.1.0",
"gatsby-plugin-react-helmet": "^3.0.12",
diff --git a/schema.graphql b/schema.graphql
index b7194ae..589b3c0 100644
--- a/schema.graphql
+++ b/schema.graphql
@@ -15,5 +15,5 @@ type Frontmatter {
title: String
text: String
linkText: String
- image: File
+ image: File @addResolver(type: "fileByRelativePath")
} |
@pieh awesome! I just tried that on my build and it does seem to resolve the issue. Any idea when this feature might land? I think we can manually manage the data for a while... I'd rather go with a full stable release if possible since this is for a client site. Also, should I close this issue then? or will it closed by the PR? |
@kara-todd Glad to hear that @pieh was able to help solve the problem. Since #13028 was merged 9 days ago, I'll close this issue. Feel free to reopen if questions remain. |
Description
Empty string value throws an error for image paths when manually defined with a
schema.graphql
file.Note, this only seems to happen when using a Netlify style
/static
directory and re-writing frontmatter image paths to be relative.Steps to reproduce:
git clone --branch broken [email protected]:kara-todd/gastby-image-bug.git
yarn install; yarn develop
http://localhost:8000/
andhttp://localhost:8000/___graphql
http://localhost:8000/___graphql
and run the following:Expected result
Image ids should be returned for all provided images, and null for empty image strings:
Actual result
An array of errors containing
"message": "Cannot return null for non-nullable field File.id.",
Environment
gatsby info --clipboard
Please note if you clone my repo above I misspelled "gatsby" as "gastby" due to my dyslexia... 🤦♀️
The text was updated successfully, but these errors were encountered: