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

feat: feature admin API returns dependencies and children #4848

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Sep 27, 2023

About the changes

Admin feature API returns dependencies and children

Screenshot 2023-09-27 at 14 59 54 Screenshot 2023-09-27 at 14 59 36

Details:

  • added OpenAPI types
  • added 2 read model operations for a single feature (read parents, read children)
  • added a test verifying that everything works e2e
  • making typechecker happy where introducing new read model dependency broke the expectations

Important files

Discussion points

I decided not to touch the big features_view for now. Reasons: it's already difficult to reason about + for common parents it would generate lots of new rows

@vercel
Copy link

vercel bot commented Sep 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Sep 27, 2023 0:58am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 27, 2023 0:58am

export interface IDependentFeaturesReadModel {
getChildren(parent: string): Promise<string[]>;
getParents(child: string): Promise<string[]>;
getParents(child: string): Promise<IDependency[]>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

currently we only need string but I want to have API that will be prepared for the upcoming enhancements (variants, enabled/disabled)

return rows.map((row) => ({
feature: row.parent,
enabled: row.enabled,
variants: row.variants,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was surprised that JSON.parse is not needed here

@@ -157,6 +160,8 @@ class FeatureToggleService {

private privateProjectChecker: IPrivateProjectChecker;

private dependentFeaturesReadModel: IDependentFeaturesReadModel;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we only depend on read operations in a different module

if (projectId) {
await this.validateFeatureBelongsToProject({
featureName,
projectId,
});
}

let dependencies: IDependency[] = [];
let children: string[] = [];
if (this.flagResolver.isEnabled('dependentFeatures')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we do optional enhancement with parent/child information

@@ -3394,3 +3395,29 @@ test('should not be allowed to update with invalid strategy type name', async ()
400,
);
});

test('should list dependencies and children', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this shows how this new feature works

const child = uuidv4();
await app.createFeature(parent, 'default');
await app.createFeature(child, 'default');
await app.addDependency(child, parent);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this new method since it may come in handy and also code is symmetrical when we do everything with app.doXYZ

@kwasniew kwasniew changed the title Return feature dependencies admin api feat: feature dependencies admin api Sep 27, 2023
@kwasniew kwasniew changed the title feat: feature dependencies admin api feat: feature admin API returns dependencies and children Sep 27, 2023
Copy link
Contributor

@FredrikOseberg FredrikOseberg left a comment

Choose a reason for hiding this comment

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

LGTM

@kwasniew kwasniew merged commit 87a8112 into main Sep 27, 2023
8 checks passed
@kwasniew kwasniew deleted the return-feature-dependencies-admin-api branch September 27, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants