prismic-gatsby: Data returning null
Description:
LocalFile and StructureText data is returned as null, whereas it is available in the dataRaw.
Data:
{
"data": {
"allPrismicPageTemplate": {
"edges": [
{
"node": {
"data": {
"background_image": {
"localFile": null
},
"left_content_copy": {
"text": null
}
},
"dataRaw": {
"page_title": [
{
"type": "heading1",
"text": "Test page template",
"spans": []
}
],
"background_image": {
"dimensions": {
"width": 1667,
"height": 1003
},
"alt": null,
"copyright": null,
"url": "https://images.prismic.io/raecreative%2Fba4837cb-d2ed-42fb-9b68-4c8c9d4a5a8d_collection_management_campaign_editorial.jpg?auto=compress,format"
},
"left_content_copy": [
{
"type": "paragraph",
"text": "Some left hand content",
"spans": []
}
],
"right_content_copy": [
{
"type": "paragraph",
"text": "Some right hand content",
"spans": []
}
],
"right_content_video": {
"link_type": "Media",
"name": "RC Behind The Scenes FINAL_web quality.mp4",
"kind": "document",
"url": "https://raecreative.cdn.prismic.io/raecreative%2F6eb0e38b-827e-46d7-9695-3ce15a068ca1_rc+behind+the+scenes+final_web+quality.mp4",
"size": "51702480"
},
"right_content_image": {
"dimensions": {
"width": 3840,
"height": 5760
},
"alt": null,
"copyright": null,
"url": "https://images.prismic.io/raecreative%2F374a22bf-0ecd-4ef4-91da-e48eb73354f3_4.jpg?auto=compress,format"
}
}
}
}
]
}
}
}
Version:
"gatsby-source-prismic": "^3.0.0-beta.14",
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 23 (8 by maintainers)
Big thanks to @angeloashmore for his help.
tl;dr Make sure to use the correct API IDs for Prismic. Do not convert
foo-bartofooBar.Summary
If your API ID in Prismic uses a
-like inpage-foo, make sure you use'page-foo': require('./src/schemas/page-foo.json')the schema definition in yourgatsby-config.js✅ Correct
‼️ Wrong
This may look like it works, but it does not! The key for the data will not match up and you’ll get issues like this one here.
Improvements
As I understand @angeloashmore is planning to add some checks, to make sure this mistake gets detected automatically and you ll be warned.
Be aware
Technically you could setup two prismic types named
foo-barandfooBar. Just … just don’t do that, okay?Hey @mrseanbaines (sorry for the delayed response!) and @larsenwork,
This definitely looks related to the
transformFieldNameoption. I’ll investigate and let you know what I find!Thanks @angeloashmore! I had to continue without the camelCasing so I’ll need to do some refactoring at some point to try this out. Will let you know how it goes when I get the chance
I can confirm that it fixes my issue. Thanks 🙏
I’m using the v4 beta plugin and I think I have a similar issue. I was camelCasing field names with the
transformFieldNameconfig option and also using the custom types API with thecustomTypesApiTokenconfig option:This initially seemed to work, as the field names were camelCased in the GraphiQL editor, but anything that was more than one word would just return null (since single word fields are the same in snake_case and camelCase):
When removing the
transformFieldNameoption, it return the correct value (but no camelCasing ☹️):Is this the same issue, or should I write up a separate issue for this @angeloashmore? This feels like a bug with the
transformFieldNameoption (or maybecustomTypesApiToken, or a combination of the two).Version:
"gatsby-source-prismic": "4.0.0-beta.17"@rubas Yes, that would be helpful. Just the schema that’s failing should be enough. You could send me a secret Gist link via Twitter (@angeloashmore).