-
Notifications
You must be signed in to change notification settings - Fork 1
/
ent.resolvers.go
159 lines (142 loc) · 6.26 KB
/
ent.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package entproject
// 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.29
import (
"context"
"fmt"
"entgo.io/contrib/entgql"
"github.com/entkit/entkit-demo/ent"
"github.com/google/uuid"
)
// Node is the resolver for the node field.
func (r *queryResolver) Node(ctx context.Context, id uuid.UUID) (ent.Noder, error) {
panic(fmt.Errorf("not implemented"))
}
// Nodes is the resolver for the nodes field.
func (r *queryResolver) Nodes(ctx context.Context, ids []uuid.UUID) ([]ent.Noder, error) {
panic(fmt.Errorf("not implemented"))
}
// Companies is the resolver for the companies field.
func (r *queryResolver) Companies(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.CompanyOrder, where *ent.CompanyWhereInput, q *string) (*ent.CompanyConnection, error) {
err := ent.DemoEnforceCompanyRead(ctx)
if err != nil {
return nil, err
}
return r.client.Company.Query().
Paginate(ctx, after, first, before, last,
ent.WithCompanyOrder(orderBy),
ent.WithCompanyFilter(where.ApplySearchQuery(q).Filter),
)
}
// Countries is the resolver for the countries field.
func (r *queryResolver) Countries(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.CountryOrder, where *ent.CountryWhereInput, q *string) (*ent.CountryConnection, error) {
err := ent.DemoEnforceCountryRead(ctx)
if err != nil {
return nil, err
}
return r.client.Country.Query().
Paginate(ctx, after, first, before, last,
ent.WithCountryOrder(orderBy),
ent.WithCountryFilter(where.ApplySearchQuery(q).Filter),
)
}
// Emails is the resolver for the emails field.
func (r *queryResolver) Emails(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.EmailOrder, where *ent.EmailWhereInput, q *string) (*ent.EmailConnection, error) {
err := ent.DemoEnforceEmailRead(ctx)
if err != nil {
return nil, err
}
return r.client.Email.Query().
Paginate(ctx, after, first, before, last,
ent.WithEmailOrder(orderBy),
ent.WithEmailFilter(where.ApplySearchQuery(q).Filter),
)
}
// Images is the resolver for the images field.
func (r *queryResolver) Images(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.ImageOrder, where *ent.ImageWhereInput, q *string) (*ent.ImageConnection, error) {
err := ent.DemoEnforceImageRead(ctx)
if err != nil {
return nil, err
}
return r.client.Image.Query().
Paginate(ctx, after, first, before, last,
ent.WithImageOrder(orderBy),
ent.WithImageFilter(where.ApplySearchQuery(q).Filter),
)
}
// Locations is the resolver for the locations field.
func (r *queryResolver) Locations(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.LocationOrder, where *ent.LocationWhereInput, q *string) (*ent.LocationConnection, error) {
err := ent.DemoEnforceLocationRead(ctx)
if err != nil {
return nil, err
}
return r.client.Location.Query().
Paginate(ctx, after, first, before, last,
ent.WithLocationOrder(orderBy),
ent.WithLocationFilter(where.ApplySearchQuery(q).Filter),
)
}
// Phones is the resolver for the phones field.
func (r *queryResolver) Phones(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.PhoneOrder, where *ent.PhoneWhereInput, q *string) (*ent.PhoneConnection, error) {
err := ent.DemoEnforcePhoneRead(ctx)
if err != nil {
return nil, err
}
return r.client.Phone.Query().
Paginate(ctx, after, first, before, last,
ent.WithPhoneOrder(orderBy),
ent.WithPhoneFilter(where.ApplySearchQuery(q).Filter),
)
}
// Products is the resolver for the products field.
func (r *queryResolver) Products(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.ProductOrder, where *ent.ProductWhereInput, q *string) (*ent.ProductConnection, error) {
err := ent.DemoEnforceProductRead(ctx)
if err != nil {
return nil, err
}
return r.client.Product.Query().
Paginate(ctx, after, first, before, last,
ent.WithProductOrder(orderBy),
ent.WithProductFilter(where.ApplySearchQuery(q).Filter),
)
}
// Vendors is the resolver for the vendors field.
func (r *queryResolver) Vendors(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.VendorOrder, where *ent.VendorWhereInput, q *string) (*ent.VendorConnection, error) {
err := ent.DemoEnforceVendorRead(ctx)
if err != nil {
return nil, err
}
return r.client.Vendor.Query().
Paginate(ctx, after, first, before, last,
ent.WithVendorOrder(orderBy),
ent.WithVendorFilter(where.ApplySearchQuery(q).Filter),
)
}
// Warehouses is the resolver for the warehouses field.
func (r *queryResolver) Warehouses(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.WarehouseOrder, where *ent.WarehouseWhereInput, q *string) (*ent.WarehouseConnection, error) {
err := ent.DemoEnforceWarehouseRead(ctx)
if err != nil {
return nil, err
}
return r.client.Warehouse.Query().
Paginate(ctx, after, first, before, last,
ent.WithWarehouseOrder(orderBy),
ent.WithWarehouseFilter(where.ApplySearchQuery(q).Filter),
)
}
// Websites is the resolver for the websites field.
func (r *queryResolver) Websites(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, orderBy *ent.WebsiteOrder, where *ent.WebsiteWhereInput, q *string) (*ent.WebsiteConnection, error) {
err := ent.DemoEnforceWebsiteRead(ctx)
if err != nil {
return nil, err
}
return r.client.Website.Query().
Paginate(ctx, after, first, before, last,
ent.WithWebsiteOrder(orderBy),
ent.WithWebsiteFilter(where.ApplySearchQuery(q).Filter),
)
}
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
type queryResolver struct{ *Resolver }