hydra
hydra copied to clipboard
Array of enums not supported
There is no way how to create a list of enums.
The following input schema will generate uncompilable code:
enum ChannelActionPermission {
UpdateChannelMetadata
ManageNonVideoChannelAssets
ManageChannelCollaborators
UpdateVideoMetadata
AddVideo
ManageVideoAssets
DeleteChannel
DeleteVideo
ManageVideoNfts
AgentRemark
TransferChannel
ClaimChannelReward
WithdrawFromChannelBalance
IssueCreatorToken
ClaimCreatorTokenPatronage
InitAndManageCreatorTokenSale
CreatorTokenIssuerTransfer
MakeCreatorTokenPermissionless
ReduceCreatorTokenPatronageRate
ManageRevenueSplits
DeissueCreatorToken
}
type ChannelAgentPermissions @entity {
...
"List of member's permissions"
permissions: [ChannelActionPermission!]!
}
The generated snippet in channel-agent-permissions.model.ts
doesn't represent the schema (there is enum instead of array of enums created):
@EnumField('ChannelActionPermission', ChannelActionPermission, {
description: `List of member's permissions`,
})
permissions!: ChannelActionPermission;
After manually changing the generated code to
@EnumField('ChannelActionPermission', ChannelActionPermission, {
description: `List of member's permissions`,
array: true, // none of these two works
isArray: true, // none of these two works
})
permissions!: ChannelActionPermission[];
the code compiles, but an error during db setup occurs:
DataTypeNotSupportedError: Data type "Array" in "ChannelAgentPermissions.permissions" is not supported by "postgres" database
This will require a change in Warthog's EnumField
decorator. I wasn't able to make it work in a couple of hours, so I'm putting it on ice for now.