-
Notifications
You must be signed in to change notification settings - Fork 32
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
bug(gatsby-source-strapi): Cannot read properties of undefined (reading 'split') #383
Comments
Not sure if this should be resolved in the plugin level, or I should tweak my settings in Strapi, or I did something wrong in Gatsby. |
Saw @laurenskling helps maintain this plugin. Tag for notify |
I'm not too familiar with So based on your logs, If you call the API endpoints yourself, is the data also inconsistent in have |
I dug in a bit more. It doesn't seem like it's merely the So, on the Strapi side, the richtext is stored in the markdown format. It's always string. Things look okay in this regard. All the richtext object stuffs happen after Strapi GraphQL Playground {
"data": {
"usersPermissionsUsers": {
"data": [
{
"attributes": {
"editor": {
"data": {
"attributes": {
"bio": "**Chia-Sheng** is an experienced engineer with a strong background in .NET related technologies, including C# and Azure. He is proficient in React.js and previously worked with Ruby on Rails. While he's not coding, **Chia-Sheng** enjoys traveling and playing football."
}
}
}
}
}
]
}
}
} But on the gatsby side,
I assume the issue has something to do with
I will switch the one-to-one to other type to have a quick experiment. Other than that, I have no idea how to progress. |
Still can't find Posting my {
resolve: "gatsby-source-strapi",
options: {
apiURL: process.env.STRAPI_API_URL,
accessToken: process.env.STRAPI_TOKEN,
collectionTypes: ["post", "editor", "user"],
singleTypes: [],
},
}, |
Ah. You are not populating your relations: |
Thanks! I'll give it a try. |
I agree the docs aren't giving a lot of examples on doing this. Any help on this would be welcome. Its also hard from Strapi side of things, their docs about populating is also hard to understand. I guess you just need to figure out what works for you. you should always need to reference your relations. https://docs.strapi.io/dev-docs/api/rest/populate-select#population
is enough. |
Describe the bug
When
gatsby build
, the error "Cannot read properties of undefined (reading 'split')" is raised. After investigating, I have narrowed down the issue to the following content type schema:User
content type (from permission-user plugin) has a one-to-one relationship with theEditor
content type.Post
content type has a belongs-to relationship with theEditor
content type.Editor
content type has a richtext field calledbio
.The issue arises when the
bio
field in theUser
content type'seditor
relation is in string format, while the plugin expects it to be in richtext object format.See these source codes, in the setting above it would be equivalent to
extraftFiles(undefined, apiURL)
, then it causes the error.Noted that the
bio
field in thePost
content type'seditor
relation is in the correct richtext object format with the following structure:Proof of Concept
I've added several log lines inside the function
download-media-files.extractImages()
.Part 1
Part 2
The log
The log is as follow, omitting unimportant parts.
In the log, we see that the value for the
api::post.post
relationship is an object with abio
property, where thebio
property is itself an object with adata
property and amedias
property. Thedata
property contains a string value with some biographical information about a person.On the other hand, the value for the
plugin::users-permissions.user
relationship is a string containing the same biographical information as thedata
property in the first schema.System Info
https://github.com/cschenio/blog
Error Log
This is the log for
yarn run build --verbose
.The text was updated successfully, but these errors were encountered: