-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct
Code Sandbox link
No response
Bug report
conditionalByType ignores part of the result in a specific scenario.
When one type (e.g. 'heroSection') has its own parser, but another (e.g. 'block') does not, then the result for the latter is ignored during parsing.
This happens because conditionalParser returns an empty object in this case.
This does not work:
conditionalByType({
block: { // result is { _type: 'block' }
children: true,
style: true,
listItem: true,
markDefs: true,
level: true,
},
heroSection: (heroSection) => ({
title: true,
description: true,
photos: heroSection.field("photos[]").project((photo) => ({
src: photo.field("image").field("asset").deref().field("url"),
alt: true,
caption: true,
})),
columns,
})
})
But this does:
conditionalByType({
block: { // result is { _type: 'block', children: ..., style: ..., etc... }
children: true,
style: q.string(),
listItem: true,
markDefs: true,
level: true,
},
heroSection: (heroSection) => ({
title: true,
description: true,
photos: heroSection.field("photos[]").project((photo) => ({
src: photo.field("image").field("asset").deref().field("url"),
alt: true,
caption: true,
})),
columns,
})
})
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working