Skip to content

Commit

Permalink
Merge pull request #7 from giogaspa/fix/error-in-the-selection-of-rel…
Browse files Browse the repository at this point in the history
…ations

Fix: No relation attribute selected
  • Loading branch information
raiindev authored Oct 1, 2024
2 parents 231e057 + 90b7871 commit f95eee5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/services/content-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ const shouldAttributeBeIncluded = (attribute, includedRelations) => {

const getSelectedRelations = ({ schema, relations }) => {
return relations.reduce((acc, relation) => {
acc[relation] = {
select: Object.keys(schema[relation]).map((key) => key)
if (relation in schema) {
acc[relation] = {
select: Object.keys(schema[relation]).map((key) => key)
}
}

return acc
}, {})
}

const getSelectedFieldsConfigObj = (schema) =>
Object.entries(schema).reduce((acc, [key, value]) => (typeof value === 'object' ? acc : [...acc, key]), ['id'])

Expand Down

0 comments on commit f95eee5

Please sign in to comment.