Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add featureFlag gateDecorator for sync-metadata #2956

Merged
merged 5 commits into from
Dec 12, 2023

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Dec 12, 2023

Context

Fixes #2924
We want to start to work on email integrations and add new models. However, those models should not impact all workspaces during our implementations (which will take a few sprints) so we should be able to edit or create a standard object and sync-metadata command should skip those modifications.

Realistically, the only way I see it for now is to add a parameter to ObjectMetadata / FieldMetadata decorators, if the sync-metadata service sees this, it should skip the field or the object entirely, meaning it will consider it does not exist OR does not exist anymore and will do the changes accordingly, except for workspaces with the flag. This brings some limitations but should be enough for this use case

Implementation

As explained above, this PR introduces a new GateDecorator that we can add on our standard Objects/Fields. For now you can provide a featureFlag parameter and we will make sure to match it with feature flags stored in the DB. If the flag is not present, we skip the object or field creation.
This has some limitations but should be enough for our needs for now.
Note: For relations, make sure you also gate both directions

@ObjectMetadata({
  namePlural: 'messages',
  labelSingular: 'Message',
  labelPlural: 'Message',
  description: 'Messages',
  icon: 'IconMessage',
})
@Gate({
  featureFlag: 'IS_MESSAGING_ENABLED',
})
@IsSystem()
export class MessageObjectMetadata extends BaseObjectMetadata {}

&&

[...]
export class MessageThreadObjectMetadata extends BaseObjectMetadata {
[...]
  @FieldMetadata({
    type: FieldMetadataType.RELATION,
    label: 'Messages',
    description: 'Messages',
    icon: 'IconMessage',
  })
  @RelationMetadata({
    type: RelationMetadataType.ONE_TO_MANY,
    objectName: 'message',
  })
  @IsNullable()
  @Gate({
    featureFlag: 'IS_MESSAGING_ENABLED',
  })
  messages: MessageObjectMetadata[];

@Weiko Weiko force-pushed the c--add-feature-flag-gate-decorator-for-metadata-sync branch from 050f855 to 26876ec Compare December 12, 2023 16:20
Copy link
Member

@magrinj magrinj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, LGTM !

@Weiko Weiko merged commit f126bd9 into main Dec 12, 2023
5 of 10 checks passed
@Weiko Weiko deleted the c--add-feature-flag-gate-decorator-for-metadata-sync branch December 12, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Standard-objects ObjectMetadata/FieldMetadata can be locked behind a featureFlag
2 participants