You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since "parent" and "children" are reserved keywords in gatsby, this plugin automatically appends "strapi_" to the relation name. Since the relations are now named "strapi_parent" and "strapi_children" the code on this line doesn't work, https://github.com/strapi/gatsby-source-strapi/blob/2a60320b16ae6520617d743158c433d384dbd155/src/download-media-files.js#L117, since the relations on the strapi schema are named just "parent" and "children", but attributeName is "strapi_parent" and "strapi_children".
This problem is related to the other issue I have with relations: gatsby-uc/gatsby-source-strapi#308, because without changing the code to schema.schema.attributes[attributeName.replace('strapi_', '')] the fix I illustrated in the other issue doesn't work because the fields generated from this plugin and the schema on strapi are different
The text was updated successfully, but these errors were encountered:
Hi @soupette, I understand that those names are forbidden in gatsby and that's why they are prefixed with strapi_, the problem is that this change is not reflected when getting the data from the strapi schema when downloading images.
Inside this line of code const attribute = schema.schema.attributes[attributeName]; the schema.schema.attributes has the children and parent fields (because it is fetched from the content builder api), but they are accessed using the prefixed fields strapi_children and strapi_parent, thus returning undefined every time
Hi @soupette, I understand that those names are forbidden in gatsby and that's why they are prefixed with strapi_, the problem is that this change is not reflected when getting the data from the strapi schema when downloading images. Inside this line of code const attribute = schema.schema.attributes[attributeName]; the schema.schema.attributes has the children and parent fields (because it is fetched from the content builder api), but they are accessed using the prefixed fields strapi_children and strapi_parent, thus returning undefined every time
You are right! it's a bug indeed, would you mind opening a PR to fix the issue so we can make a new release?
moonmeister
changed the title
Relations are not picked up if they are named "parent" or "children"
bug(gatsby-source-strapi): Relations are not picked up if they are named "parent" or "children"
Dec 27, 2022
Since "parent" and "children" are reserved keywords in gatsby, this plugin automatically appends "strapi_" to the relation name. Since the relations are now named "strapi_parent" and "strapi_children" the code on this line doesn't work, https://github.com/strapi/gatsby-source-strapi/blob/2a60320b16ae6520617d743158c433d384dbd155/src/download-media-files.js#L117, since the relations on the strapi schema are named just "parent" and "children", but attributeName is "strapi_parent" and "strapi_children".
This problem is related to the other issue I have with relations: gatsby-uc/gatsby-source-strapi#308, because without changing the code to
schema.schema.attributes[attributeName.replace('strapi_', '')]
the fix I illustrated in the other issue doesn't work because the fields generated from this plugin and the schema on strapi are differentThe text was updated successfully, but these errors were encountered: