forked from project-zot/zot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentz.resolvers.go
118 lines (93 loc) · 3.48 KB
/
entz.resolvers.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package zot
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.36
import (
"context"
"fmt"
"zotregistry.io/zot/ent"
)
// Statementsq is the resolver for the statementsq field.
func (r *queryResolver) Statementsq(ctx context.Context, jsonPath *string, jsonValue *string) ([]*ent.Statement, error) {
fmt.Println("statementsq called")
fmt.Printf("jsonPath: %s\n", *jsonPath)
fmt.Printf("jsonValue: %s\n", *jsonValue)
// Query all statements from the database
query := r.client.Statement.Query()
// Apply custom predicates if needed
if jsonPath != nil && jsonValue != nil {
predicate := StatementHasJSONValue("statement", *jsonPath, *jsonValue)
query.Where(predicate) // Use the custom predicate directly
}
statements, err := query.All(ctx)
if err != nil {
return nil, err
}
return statements, nil
}
// Objectsq is the resolver for the objectsq field.
func (r *queryResolver) Objectsq(ctx context.Context, jsonPath *string, jsonValue *string) ([]*ent.Object, error) {
fmt.Println("statementsq called")
fmt.Printf("jsonPath: %s\n", *jsonPath)
fmt.Printf("jsonValue: %s\n", *jsonValue)
// Query all statements from the database
query := r.client.Object.Query()
// Apply custom predicates if needed
if jsonPath != nil && jsonValue != nil {
predicate := ObjectHasJSONValue("object", *jsonPath, *jsonValue)
query.Where(predicate) // Use the custom predicate directly
}
objects, err := query.All(ctx)
if err != nil {
return nil, err
}
return objects, nil
}
// Predicatesq is the resolver for the predicatesq field.
func (r *queryResolver) Predicatesq(ctx context.Context, jsonPath *string, jsonValue *string) ([]*ent.Spredicate, error) {
fmt.Println("predicatesq called")
fmt.Printf("jsonPath: %s\n", *jsonPath)
fmt.Printf("jsonValue: %s\n", *jsonValue)
// Query all statements from the database
query := r.client.Spredicate.Query()
// Apply custom predicates if needed
if jsonPath != nil && jsonValue != nil {
predicate := PredicateHasJSONValue("predicate", *jsonPath, *jsonValue)
query.Where(predicate) // Use the custom predicate directly
}
spredicates, err := query.All(ctx)
if err != nil {
return nil, err
}
return spredicates, nil
}
// Subjectsq is the resolver for the subjectsq field.
func (r *queryResolver) Subjectsq(ctx context.Context, jsonPath *string, jsonValue *string) ([]*ent.Subject, error) {
fmt.Println("subjectsq called")
fmt.Printf("jsonPath: %s\n", *jsonPath)
fmt.Printf("jsonValue: %s\n", *jsonValue)
// Query all statements from the database
query := r.client.Subject.Query()
// Apply custom predicates if needed
if jsonPath != nil && jsonValue != nil {
predicate := SubjectHasJSONValue("subject", *jsonPath, *jsonValue)
query.Where(predicate) // Use the custom predicate directly
}
subjects, err := query.All(ctx)
if err != nil {
return nil, err
}
return subjects, nil
}
// JSONPath is the resolver for the jsonPath field.
func (r *statementWhereInputResolver) JSONPath(ctx context.Context, obj *ent.StatementWhereInput, data *string) error {
cctx := ctx.(*CustomContext)
cctx.JsonPath = data
return nil
}
// JSONValue is the resolver for the jsonValue field.
func (r *statementWhereInputResolver) JSONValue(ctx context.Context, obj *ent.StatementWhereInput, data *string) error {
cctx := ctx.(*CustomContext)
cctx.JsonValue = data
return nil
}