-
Notifications
You must be signed in to change notification settings - Fork 896
/
runtime.go
60 lines (52 loc) · 2.1 KB
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by entc, DO NOT EDIT.
package runtime
import (
"context"
"github.com/facebookincubator/ent/entc/integration/privacy/ent/galaxy"
"github.com/facebookincubator/ent/entc/integration/privacy/ent/planet"
"github.com/facebookincubator/ent/entc/integration/privacy/ent/schema"
"github.com/facebookincubator/ent"
)
// The init function reads all schema descriptors with runtime
// code (default values, validators or hooks) and stitches it
// to their package variables.
func init() {
galaxy.Policy = schema.Galaxy{}.Policy()
galaxy.Hooks[0] = func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if err := galaxy.Policy.EvalMutation(ctx, m); err != nil {
return nil, err
}
return next.Mutate(ctx, m)
})
}
galaxyFields := schema.Galaxy{}.Fields()
_ = galaxyFields
// galaxyDescName is the schema descriptor for name field.
galaxyDescName := galaxyFields[0].Descriptor()
// galaxy.NameValidator is a validator for the "name" field. It is called by the builders before save.
galaxy.NameValidator = galaxyDescName.Validators[0].(func(string) error)
planet.Policy = schema.Planet{}.Policy()
planet.Hooks[0] = func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if err := planet.Policy.EvalMutation(ctx, m); err != nil {
return nil, err
}
return next.Mutate(ctx, m)
})
}
planetHooks := schema.Planet{}.Hooks()
planet.Hooks[1] = planetHooks[0]
planetFields := schema.Planet{}.Fields()
_ = planetFields
// planetDescName is the schema descriptor for name field.
planetDescName := planetFields[0].Descriptor()
// planet.NameValidator is a validator for the "name" field. It is called by the builders before save.
planet.NameValidator = planetDescName.Validators[0].(func(string) error)
}
const (
Version = "(devel)" // Version of ent codegen.
)