hook

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedError

func FixedError(err error) generated.Hook

FixedError is a hook returning a fixed error.

func If

func If(hk generated.Hook, cond Condition) generated.Hook

If executes the given hook under condition.

hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))

func On

On executes the given hook only for the given operation.

hook.On(Log, generated.Delete|generated.Create)

func Reject

func Reject(op generated.Op) generated.Hook

Reject returns a hook that rejects all operations that match op.

func (T) Hooks() []generated.Hook {
	return []generated.Hook{
		Reject(generated.Delete|generated.Update),
	}
}

func Unless

func Unless(hk generated.Hook, op generated.Op) generated.Hook

Unless skips the given hook only for the given operation.

hook.Unless(Log, generated.Update|generated.UpdateOne)

Types

type APITokenFunc added in v0.5.0

The APITokenFunc type is an adapter to allow the use of ordinary function as APIToken mutator.

func (APITokenFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

Chain acts as a list of hooks and is effectively immutable. Once created, it will always hold the same set of hooks in the same order.

func NewChain

func NewChain(hooks ...generated.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

func (c Chain) Append(hooks ...generated.Hook) Chain

Append extends a chain, adding the specified hook as the last ones in the mutation flow.

func (Chain) Extend

func (c Chain) Extend(chain Chain) Chain

Extend extends a chain, adding the specified chain as the last ones in the mutation flow.

func (Chain) Hook

func (c Chain) Hook() generated.Hook

Hook chains the list of hooks and returns the final hook.

type Condition

type Condition func(context.Context, generated.Mutation) bool

Condition is a hook condition function.

func And

func And(first, second Condition, rest ...Condition) Condition

And groups conditions with the AND operator.

func HasAddedFields

func HasAddedFields(field string, fields ...string) Condition

HasAddedFields is a condition validating `.AddedField` on fields.

func HasClearedFields

func HasClearedFields(field string, fields ...string) Condition

HasClearedFields is a condition validating `.FieldCleared` on fields.

func HasFields

func HasFields(field string, fields ...string) Condition

HasFields is a condition validating `.Field` on fields.

func HasOp

func HasOp(op generated.Op) Condition

HasOp is a condition testing mutation operation.

func Not

func Not(cond Condition) Condition

Not negates a given condition.

func Or

func Or(first, second Condition, rest ...Condition) Condition

Or groups conditions with the OR operator.

type DocumentDataFunc added in v0.4.4

The DocumentDataFunc type is an adapter to allow the use of ordinary function as DocumentData mutator.

func (DocumentDataFunc) Mutate added in v0.4.4

Mutate calls f(ctx, m).

type DocumentDataHistoryFunc added in v0.4.5

type DocumentDataHistoryFunc func(context.Context, *generated.DocumentDataHistoryMutation) (generated.Value, error)

The DocumentDataHistoryFunc type is an adapter to allow the use of ordinary function as DocumentDataHistory mutator.

func (DocumentDataHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type EmailVerificationTokenFunc added in v0.2.2

type EmailVerificationTokenFunc func(context.Context, *generated.EmailVerificationTokenMutation) (generated.Value, error)

The EmailVerificationTokenFunc type is an adapter to allow the use of ordinary function as EmailVerificationToken mutator.

func (EmailVerificationTokenFunc) Mutate added in v0.2.2

Mutate calls f(ctx, m).

type EntitlementFunc

The EntitlementFunc type is an adapter to allow the use of ordinary function as Entitlement mutator.

func (EntitlementFunc) Mutate

Mutate calls f(ctx, m).

type EntitlementHistoryFunc added in v0.4.5

type EntitlementHistoryFunc func(context.Context, *generated.EntitlementHistoryMutation) (generated.Value, error)

The EntitlementHistoryFunc type is an adapter to allow the use of ordinary function as EntitlementHistory mutator.

func (EntitlementHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type EventFunc added in v0.5.0

The EventFunc type is an adapter to allow the use of ordinary function as Event mutator.

func (EventFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type EventHistoryFunc added in v0.5.0

The EventHistoryFunc type is an adapter to allow the use of ordinary function as EventHistory mutator.

func (EventHistoryFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type FeatureFunc added in v0.5.0

The FeatureFunc type is an adapter to allow the use of ordinary function as Feature mutator.

func (FeatureFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type FeatureHistoryFunc added in v0.5.0

type FeatureHistoryFunc func(context.Context, *generated.FeatureHistoryMutation) (generated.Value, error)

The FeatureHistoryFunc type is an adapter to allow the use of ordinary function as FeatureHistory mutator.

func (FeatureHistoryFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type FileFunc added in v0.5.0

The FileFunc type is an adapter to allow the use of ordinary function as File mutator.

func (FileFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type FileHistoryFunc added in v0.5.0

The FileHistoryFunc type is an adapter to allow the use of ordinary function as FileHistory mutator.

func (FileHistoryFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type GroupFunc

The GroupFunc type is an adapter to allow the use of ordinary function as Group mutator.

func (GroupFunc) Mutate

Mutate calls f(ctx, m).

type GroupHistoryFunc added in v0.4.5

The GroupHistoryFunc type is an adapter to allow the use of ordinary function as GroupHistory mutator.

func (GroupHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type GroupMembershipFunc added in v0.2.4

type GroupMembershipFunc func(context.Context, *generated.GroupMembershipMutation) (generated.Value, error)

The GroupMembershipFunc type is an adapter to allow the use of ordinary function as GroupMembership mutator.

func (GroupMembershipFunc) Mutate added in v0.2.4

Mutate calls f(ctx, m).

type GroupMembershipHistoryFunc added in v0.4.5

type GroupMembershipHistoryFunc func(context.Context, *generated.GroupMembershipHistoryMutation) (generated.Value, error)

The GroupMembershipHistoryFunc type is an adapter to allow the use of ordinary function as GroupMembershipHistory mutator.

func (GroupMembershipHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type GroupSettingFunc

The GroupSettingFunc type is an adapter to allow the use of ordinary function as GroupSetting mutator.

func (GroupSettingFunc) Mutate

Mutate calls f(ctx, m).

type GroupSettingHistoryFunc added in v0.4.5

type GroupSettingHistoryFunc func(context.Context, *generated.GroupSettingHistoryMutation) (generated.Value, error)

The GroupSettingHistoryFunc type is an adapter to allow the use of ordinary function as GroupSettingHistory mutator.

func (GroupSettingHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type HushFunc added in v0.5.0

The HushFunc type is an adapter to allow the use of ordinary function as Hush mutator.

func (HushFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type HushHistoryFunc added in v0.5.0

The HushHistoryFunc type is an adapter to allow the use of ordinary function as HushHistory mutator.

func (HushHistoryFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type IntegrationFunc

The IntegrationFunc type is an adapter to allow the use of ordinary function as Integration mutator.

func (IntegrationFunc) Mutate

Mutate calls f(ctx, m).

type IntegrationHistoryFunc added in v0.4.5

type IntegrationHistoryFunc func(context.Context, *generated.IntegrationHistoryMutation) (generated.Value, error)

The IntegrationHistoryFunc type is an adapter to allow the use of ordinary function as IntegrationHistory mutator.

func (IntegrationHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type InviteFunc added in v0.2.6

The InviteFunc type is an adapter to allow the use of ordinary function as Invite mutator.

func (InviteFunc) Mutate added in v0.2.6

Mutate calls f(ctx, m).

type OauthProviderFunc

type OauthProviderFunc func(context.Context, *generated.OauthProviderMutation) (generated.Value, error)

The OauthProviderFunc type is an adapter to allow the use of ordinary function as OauthProvider mutator.

func (OauthProviderFunc) Mutate

Mutate calls f(ctx, m).

type OauthProviderHistoryFunc added in v0.4.5

type OauthProviderHistoryFunc func(context.Context, *generated.OauthProviderHistoryMutation) (generated.Value, error)

The OauthProviderHistoryFunc type is an adapter to allow the use of ordinary function as OauthProviderHistory mutator.

func (OauthProviderHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type OhAuthTooTokenFunc

type OhAuthTooTokenFunc func(context.Context, *generated.OhAuthTooTokenMutation) (generated.Value, error)

The OhAuthTooTokenFunc type is an adapter to allow the use of ordinary function as OhAuthTooToken mutator.

func (OhAuthTooTokenFunc) Mutate

Mutate calls f(ctx, m).

type OrgMembershipFunc added in v0.2.4

type OrgMembershipFunc func(context.Context, *generated.OrgMembershipMutation) (generated.Value, error)

The OrgMembershipFunc type is an adapter to allow the use of ordinary function as OrgMembership mutator.

func (OrgMembershipFunc) Mutate added in v0.2.4

Mutate calls f(ctx, m).

type OrgMembershipHistoryFunc added in v0.4.5

type OrgMembershipHistoryFunc func(context.Context, *generated.OrgMembershipHistoryMutation) (generated.Value, error)

The OrgMembershipHistoryFunc type is an adapter to allow the use of ordinary function as OrgMembershipHistory mutator.

func (OrgMembershipHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type OrganizationFunc

The OrganizationFunc type is an adapter to allow the use of ordinary function as Organization mutator.

func (OrganizationFunc) Mutate

Mutate calls f(ctx, m).

type OrganizationHistoryFunc added in v0.4.3

type OrganizationHistoryFunc func(context.Context, *generated.OrganizationHistoryMutation) (generated.Value, error)

The OrganizationHistoryFunc type is an adapter to allow the use of ordinary function as OrganizationHistory mutator.

func (OrganizationHistoryFunc) Mutate added in v0.4.3

Mutate calls f(ctx, m).

type OrganizationSettingFunc

type OrganizationSettingFunc func(context.Context, *generated.OrganizationSettingMutation) (generated.Value, error)

The OrganizationSettingFunc type is an adapter to allow the use of ordinary function as OrganizationSetting mutator.

func (OrganizationSettingFunc) Mutate

Mutate calls f(ctx, m).

type OrganizationSettingHistoryFunc added in v0.4.3

type OrganizationSettingHistoryFunc func(context.Context, *generated.OrganizationSettingHistoryMutation) (generated.Value, error)

The OrganizationSettingHistoryFunc type is an adapter to allow the use of ordinary function as OrganizationSettingHistory mutator.

func (OrganizationSettingHistoryFunc) Mutate added in v0.4.3

Mutate calls f(ctx, m).

type PasswordResetTokenFunc added in v0.2.3

type PasswordResetTokenFunc func(context.Context, *generated.PasswordResetTokenMutation) (generated.Value, error)

The PasswordResetTokenFunc type is an adapter to allow the use of ordinary function as PasswordResetToken mutator.

func (PasswordResetTokenFunc) Mutate added in v0.2.3

Mutate calls f(ctx, m).

type PersonalAccessTokenFunc

type PersonalAccessTokenFunc func(context.Context, *generated.PersonalAccessTokenMutation) (generated.Value, error)

The PersonalAccessTokenFunc type is an adapter to allow the use of ordinary function as PersonalAccessToken mutator.

func (PersonalAccessTokenFunc) Mutate

Mutate calls f(ctx, m).

type SubscriberFunc added in v0.3.6

The SubscriberFunc type is an adapter to allow the use of ordinary function as Subscriber mutator.

func (SubscriberFunc) Mutate added in v0.3.6

Mutate calls f(ctx, m).

type TFASettingFunc added in v0.4.4

The TFASettingFunc type is an adapter to allow the use of ordinary function as TFASetting mutator.

func (TFASettingFunc) Mutate added in v0.4.4

Mutate calls f(ctx, m).

type TemplateFunc added in v0.4.3

The TemplateFunc type is an adapter to allow the use of ordinary function as Template mutator.

func (TemplateFunc) Mutate added in v0.4.3

Mutate calls f(ctx, m).

type TemplateHistoryFunc added in v0.4.5

type TemplateHistoryFunc func(context.Context, *generated.TemplateHistoryMutation) (generated.Value, error)

The TemplateHistoryFunc type is an adapter to allow the use of ordinary function as TemplateHistory mutator.

func (TemplateHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type UserFunc

The UserFunc type is an adapter to allow the use of ordinary function as User mutator.

func (UserFunc) Mutate

Mutate calls f(ctx, m).

type UserHistoryFunc added in v0.4.5

The UserHistoryFunc type is an adapter to allow the use of ordinary function as UserHistory mutator.

func (UserHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type UserSettingFunc

The UserSettingFunc type is an adapter to allow the use of ordinary function as UserSetting mutator.

func (UserSettingFunc) Mutate

Mutate calls f(ctx, m).

type UserSettingHistoryFunc added in v0.4.5

type UserSettingHistoryFunc func(context.Context, *generated.UserSettingHistoryMutation) (generated.Value, error)

The UserSettingHistoryFunc type is an adapter to allow the use of ordinary function as UserSettingHistory mutator.

func (UserSettingHistoryFunc) Mutate added in v0.4.5

Mutate calls f(ctx, m).

type WebauthnFunc added in v0.3.0

The WebauthnFunc type is an adapter to allow the use of ordinary function as Webauthn mutator.

func (WebauthnFunc) Mutate added in v0.3.0

Mutate calls f(ctx, m).

type WebhookFunc added in v0.5.0

The WebhookFunc type is an adapter to allow the use of ordinary function as Webhook mutator.

func (WebhookFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type WebhookHistoryFunc added in v0.5.0

type WebhookHistoryFunc func(context.Context, *generated.WebhookHistoryMutation) (generated.Value, error)

The WebhookHistoryFunc type is an adapter to allow the use of ordinary function as WebhookHistory mutator.

func (WebhookHistoryFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL