Skip to content

Commit

Permalink
switch from global to per-rule continue option (#3924)
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercactapus authored and AllenDing committed Jul 2, 2024
1 parent 56da39b commit 6a584a4
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 107 deletions.
154 changes: 78 additions & 76 deletions graphql2/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions graphql2/graph/univkeys.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ extend type Mutation {
}

type KeyConfig {
"""
Stop evaluating rules after the first rule that matches.
"""
stopAtFirstRule: Boolean!

rules: [KeyRule!]!

"""
Expand All @@ -79,16 +74,16 @@ type KeyRule {
conditionExpr: ExprBooleanExpression!

actions: [Action!]!

"""
Continue evaluating rules after this rule matches.
"""
continueAfterMatch: Boolean!
}

input UpdateKeyConfigInput {
keyID: ID!

"""
Stop evaluating rules after the first rule that matches.
"""
stopAtFirstRule: Boolean

rules: [KeyRuleInput!]

"""
Expand Down Expand Up @@ -122,6 +117,13 @@ input KeyRuleInput {
conditionExpr: ExprBooleanExpression!

actions: [ActionInput!]!

"""
Continue evaluating rules after this rule matches.
If this is set to false (default), no further rules will be evaluated after this rule matches.
"""
continueAfterMatch: Boolean!
}

input ActionInput {
Expand Down
22 changes: 10 additions & 12 deletions graphql2/graphqlapp/integrationkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ func (m *Mutation) UpdateKeyConfig(ctx context.Context, input graphql2.UpdateKey
return err
}

if input.StopAtFirstRule != nil {
cfg.StopAfterFirstMatchingRule = *input.StopAtFirstRule
}

if input.Rules != nil {
cfg.Rules = make([]integrationkey.Rule, 0, len(input.Rules))
for _, r := range input.Rules {
Expand All @@ -121,6 +117,8 @@ func (m *Mutation) UpdateKeyConfig(ctx context.Context, input graphql2.UpdateKey
Description: r.Description,
ConditionExpr: r.ConditionExpr,
Actions: actionsGQLToGo(r.Actions),

ContinueAfterMatch: r.ContinueAfterMatch,
})
}
}
Expand Down Expand Up @@ -213,18 +211,18 @@ func (key *IntegrationKey) Config(ctx context.Context, raw *integrationkey.Integ
var rules []graphql2.KeyRule
for _, r := range cfg.Rules {
rules = append(rules, graphql2.KeyRule{
ID: r.ID.String(),
Name: r.Name,
Description: r.Description,
ConditionExpr: r.ConditionExpr,
Actions: actionsGoToGQL(r.Actions),
ID: r.ID.String(),
Name: r.Name,
Description: r.Description,
ConditionExpr: r.ConditionExpr,
Actions: actionsGoToGQL(r.Actions),
ContinueAfterMatch: r.ContinueAfterMatch,
})
}

return &graphql2.KeyConfig{
StopAtFirstRule: cfg.StopAfterFirstMatchingRule,
Rules: rules,
DefaultActions: actionsGoToGQL(cfg.DefaultActions),
Rules: rules,
DefaultActions: actionsGoToGQL(cfg.DefaultActions),
}, nil
}

Expand Down
16 changes: 9 additions & 7 deletions graphql2/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a584a4

Please sign in to comment.