Last active
October 5, 2021 11:04
-
-
Save SimeonGriggs/1de3389cbfae5b58d51c4fe9f0bf3d48 to your computer and use it in GitHub Desktop.
Call Objects using a function that will filter its child fields down to specific keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filteredObject = (name, filters = []) => ({ | |
name, | |
type: 'object', | |
fields: [ | |
{name: 'size', type: 'string', hidden: () => filters.includes('size')}, | |
{name: 'tone', type: 'string', hidden: () => filters.includes('tone')} | |
] | |
}) | |
export default { | |
name: 'article', | |
type: 'document', | |
fields: [ | |
filteredObject('title', ['size', 'tone']), | |
filteredObject('subtitle', ['size']) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment