hook

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 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 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 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 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 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 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 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 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 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 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 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 SessionFunc

The SessionFunc type is an adapter to allow the use of ordinary function as Session mutator.

func (SessionFunc) Mutate

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 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).

Jump to

Keyboard shortcuts

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