Skip to content

Commit

Permalink
chore: improve feature flag error feedback (#10304)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall authored Oct 7, 2024
1 parent 209921f commit 6c058ac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/server/dataloader/customLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,9 @@ export const featureFlagByOwnerId = (parent: RootDataLoader) => {

const missingFeatureNames = featureNames.filter((name) => !existingFeatureNameSet.has(name))
if (missingFeatureNames.length > 0) {
throw new Error(`Feature flag name(s) not found: ${missingFeatureNames.join(', ')}`)
console.error(
`Feature flag name(s) not found: ${missingFeatureNames.join(', ')}. Add the feature flag name with the addFeatureFlag mutation.`
)
}
}

Expand Down
8 changes: 8 additions & 0 deletions packages/server/graphql/private/mutations/applyFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ const applyFeatureFlag: MutationResolvers['applyFeatureFlag'] = async (
? teamIds.map((teamId) => ({teamId, featureFlagId}))
: orgIds.map((orgId) => ({orgId, featureFlagId}))

if (values.length === 0) {
return standardError(
new Error(
'No valid subjects found to apply the feature flag. Check the scope of the feature flag.'
)
)
}

await pg
.insertInto('FeatureFlagOwner')
.values(values)
Expand Down
5 changes: 5 additions & 0 deletions packages/server/graphql/public/typeDefs/FeatureFlag.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ type FeatureFlag {
Expiration date of the feature flag
"""
expiresAt: DateTime!

"""
The scope of the feature flag
"""
scope: FeatureFlagScope!
}

0 comments on commit 6c058ac

Please sign in to comment.