| 1 |
// Code generated by ent, DO NOT EDIT. |
| 2 |
|
| 3 |
package ent |
| 4 |
|
| 5 |
import ( |
| 6 |
"context" |
| 7 |
"database/sql/driver" |
| 8 |
"fmt" |
| 9 |
|
| 10 |
"entgo.io/contrib/entgql" |
| 11 |
"entgo.io/ent/dialect/sql" |
| 12 |
"github.com/99designs/gqlgen/graphql" |
| 13 |
"github.com/google/uuid" |
| 14 |
"github.com/in-toto/archivista/ent/attestation" |
| 15 |
"github.com/in-toto/archivista/ent/attestationcollection" |
| 16 |
"github.com/in-toto/archivista/ent/attestationpolicy" |
| 17 |
"github.com/in-toto/archivista/ent/dsse" |
| 18 |
"github.com/in-toto/archivista/ent/payloaddigest" |
| 19 |
"github.com/in-toto/archivista/ent/signature" |
| 20 |
"github.com/in-toto/archivista/ent/statement" |
| 21 |
"github.com/in-toto/archivista/ent/subject" |
| 22 |
"github.com/in-toto/archivista/ent/subjectdigest" |
| 23 |
"github.com/in-toto/archivista/ent/timestamp" |
| 24 |
) |
| 25 |
|
| 26 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 27 |
func (_q *AttestationQuery) CollectFields(ctx context.Context, satisfies ...string) (*AttestationQuery, error) { |
| 28 |
fc := graphql.GetFieldContext(ctx) |
| 29 |
if fc == nil { |
| 30 |
return _q, nil |
| 31 |
} |
| 32 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 33 |
return nil, err |
| 34 |
} |
| 35 |
return _q, nil |
| 36 |
} |
| 37 |
|
| 38 |
func (_q *AttestationQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 39 |
path = append([]string(nil), path...) |
| 40 |
var ( |
| 41 |
unknownSeen bool |
| 42 |
fieldSeen = make(map[string]struct{}, len(attestation.Columns)) |
| 43 |
selectedFields = []string{attestation.FieldID} |
| 44 |
) |
| 45 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 46 |
switch field.Name { |
| 47 |
|
| 48 |
case "attestationCollection": |
| 49 |
var ( |
| 50 |
alias = field.Alias |
| 51 |
path = append(path, alias) |
| 52 |
query = (&AttestationCollectionClient{config: _q.config}).Query() |
| 53 |
) |
| 54 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationcollectionImplementors)...); err != nil { |
| 55 |
return err |
| 56 |
} |
| 57 |
_q.withAttestationCollection = query |
| 58 |
case "type": |
| 59 |
if _, ok := fieldSeen[attestation.FieldType]; !ok { |
| 60 |
selectedFields = append(selectedFields, attestation.FieldType) |
| 61 |
fieldSeen[attestation.FieldType] = struct{}{} |
| 62 |
} |
| 63 |
case "id": |
| 64 |
case "__typename": |
| 65 |
default: |
| 66 |
unknownSeen = true |
| 67 |
} |
| 68 |
} |
| 69 |
if !unknownSeen { |
| 70 |
_q.Select(selectedFields...) |
| 71 |
} |
| 72 |
return nil |
| 73 |
} |
| 74 |
|
| 75 |
type attestationPaginateArgs struct { |
| 76 |
first, last *int |
| 77 |
after, before *Cursor |
| 78 |
opts []AttestationPaginateOption |
| 79 |
} |
| 80 |
|
| 81 |
func newAttestationPaginateArgs(rv map[string]any) *attestationPaginateArgs { |
| 82 |
args := &attestationPaginateArgs{} |
| 83 |
if rv == nil { |
| 84 |
return args |
| 85 |
} |
| 86 |
if v := rv[firstField]; v != nil { |
| 87 |
args.first = v.(*int) |
| 88 |
} |
| 89 |
if v := rv[lastField]; v != nil { |
| 90 |
args.last = v.(*int) |
| 91 |
} |
| 92 |
if v := rv[afterField]; v != nil { |
| 93 |
args.after = v.(*Cursor) |
| 94 |
} |
| 95 |
if v := rv[beforeField]; v != nil { |
| 96 |
args.before = v.(*Cursor) |
| 97 |
} |
| 98 |
if v, ok := rv[whereField].(*AttestationWhereInput); ok { |
| 99 |
args.opts = append(args.opts, WithAttestationFilter(v.Filter)) |
| 100 |
} |
| 101 |
return args |
| 102 |
} |
| 103 |
|
| 104 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 105 |
func (_q *AttestationCollectionQuery) CollectFields(ctx context.Context, satisfies ...string) (*AttestationCollectionQuery, error) { |
| 106 |
fc := graphql.GetFieldContext(ctx) |
| 107 |
if fc == nil { |
| 108 |
return _q, nil |
| 109 |
} |
| 110 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 111 |
return nil, err |
| 112 |
} |
| 113 |
return _q, nil |
| 114 |
} |
| 115 |
|
| 116 |
func (_q *AttestationCollectionQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 117 |
path = append([]string(nil), path...) |
| 118 |
var ( |
| 119 |
unknownSeen bool |
| 120 |
fieldSeen = make(map[string]struct{}, len(attestationcollection.Columns)) |
| 121 |
selectedFields = []string{attestationcollection.FieldID} |
| 122 |
) |
| 123 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 124 |
switch field.Name { |
| 125 |
|
| 126 |
case "attestations": |
| 127 |
var ( |
| 128 |
alias = field.Alias |
| 129 |
path = append(path, alias) |
| 130 |
query = (&AttestationClient{config: _q.config}).Query() |
| 131 |
) |
| 132 |
if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, attestationImplementors)...); err != nil { |
| 133 |
return err |
| 134 |
} |
| 135 |
_q.WithNamedAttestations(alias, func(wq *AttestationQuery) { |
| 136 |
*wq = *query |
| 137 |
}) |
| 138 |
|
| 139 |
case "statement": |
| 140 |
var ( |
| 141 |
alias = field.Alias |
| 142 |
path = append(path, alias) |
| 143 |
query = (&StatementClient{config: _q.config}).Query() |
| 144 |
) |
| 145 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { |
| 146 |
return err |
| 147 |
} |
| 148 |
_q.withStatement = query |
| 149 |
case "name": |
| 150 |
if _, ok := fieldSeen[attestationcollection.FieldName]; !ok { |
| 151 |
selectedFields = append(selectedFields, attestationcollection.FieldName) |
| 152 |
fieldSeen[attestationcollection.FieldName] = struct{}{} |
| 153 |
} |
| 154 |
case "id": |
| 155 |
case "__typename": |
| 156 |
default: |
| 157 |
unknownSeen = true |
| 158 |
} |
| 159 |
} |
| 160 |
if !unknownSeen { |
| 161 |
_q.Select(selectedFields...) |
| 162 |
} |
| 163 |
return nil |
| 164 |
} |
| 165 |
|
| 166 |
type attestationcollectionPaginateArgs struct { |
| 167 |
first, last *int |
| 168 |
after, before *Cursor |
| 169 |
opts []AttestationCollectionPaginateOption |
| 170 |
} |
| 171 |
|
| 172 |
func newAttestationCollectionPaginateArgs(rv map[string]any) *attestationcollectionPaginateArgs { |
| 173 |
args := &attestationcollectionPaginateArgs{} |
| 174 |
if rv == nil { |
| 175 |
return args |
| 176 |
} |
| 177 |
if v := rv[firstField]; v != nil { |
| 178 |
args.first = v.(*int) |
| 179 |
} |
| 180 |
if v := rv[lastField]; v != nil { |
| 181 |
args.last = v.(*int) |
| 182 |
} |
| 183 |
if v := rv[afterField]; v != nil { |
| 184 |
args.after = v.(*Cursor) |
| 185 |
} |
| 186 |
if v := rv[beforeField]; v != nil { |
| 187 |
args.before = v.(*Cursor) |
| 188 |
} |
| 189 |
if v, ok := rv[whereField].(*AttestationCollectionWhereInput); ok { |
| 190 |
args.opts = append(args.opts, WithAttestationCollectionFilter(v.Filter)) |
| 191 |
} |
| 192 |
return args |
| 193 |
} |
| 194 |
|
| 195 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 196 |
func (_q *AttestationPolicyQuery) CollectFields(ctx context.Context, satisfies ...string) (*AttestationPolicyQuery, error) { |
| 197 |
fc := graphql.GetFieldContext(ctx) |
| 198 |
if fc == nil { |
| 199 |
return _q, nil |
| 200 |
} |
| 201 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 202 |
return nil, err |
| 203 |
} |
| 204 |
return _q, nil |
| 205 |
} |
| 206 |
|
| 207 |
func (_q *AttestationPolicyQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 208 |
path = append([]string(nil), path...) |
| 209 |
var ( |
| 210 |
unknownSeen bool |
| 211 |
fieldSeen = make(map[string]struct{}, len(attestationpolicy.Columns)) |
| 212 |
selectedFields = []string{attestationpolicy.FieldID} |
| 213 |
) |
| 214 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 215 |
switch field.Name { |
| 216 |
|
| 217 |
case "statement": |
| 218 |
var ( |
| 219 |
alias = field.Alias |
| 220 |
path = append(path, alias) |
| 221 |
query = (&StatementClient{config: _q.config}).Query() |
| 222 |
) |
| 223 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { |
| 224 |
return err |
| 225 |
} |
| 226 |
_q.withStatement = query |
| 227 |
case "name": |
| 228 |
if _, ok := fieldSeen[attestationpolicy.FieldName]; !ok { |
| 229 |
selectedFields = append(selectedFields, attestationpolicy.FieldName) |
| 230 |
fieldSeen[attestationpolicy.FieldName] = struct{}{} |
| 231 |
} |
| 232 |
case "id": |
| 233 |
case "__typename": |
| 234 |
default: |
| 235 |
unknownSeen = true |
| 236 |
} |
| 237 |
} |
| 238 |
if !unknownSeen { |
| 239 |
_q.Select(selectedFields...) |
| 240 |
} |
| 241 |
return nil |
| 242 |
} |
| 243 |
|
| 244 |
type attestationpolicyPaginateArgs struct { |
| 245 |
first, last *int |
| 246 |
after, before *Cursor |
| 247 |
opts []AttestationPolicyPaginateOption |
| 248 |
} |
| 249 |
|
| 250 |
func newAttestationPolicyPaginateArgs(rv map[string]any) *attestationpolicyPaginateArgs { |
| 251 |
args := &attestationpolicyPaginateArgs{} |
| 252 |
if rv == nil { |
| 253 |
return args |
| 254 |
} |
| 255 |
if v := rv[firstField]; v != nil { |
| 256 |
args.first = v.(*int) |
| 257 |
} |
| 258 |
if v := rv[lastField]; v != nil { |
| 259 |
args.last = v.(*int) |
| 260 |
} |
| 261 |
if v := rv[afterField]; v != nil { |
| 262 |
args.after = v.(*Cursor) |
| 263 |
} |
| 264 |
if v := rv[beforeField]; v != nil { |
| 265 |
args.before = v.(*Cursor) |
| 266 |
} |
| 267 |
if v, ok := rv[whereField].(*AttestationPolicyWhereInput); ok { |
| 268 |
args.opts = append(args.opts, WithAttestationPolicyFilter(v.Filter)) |
| 269 |
} |
| 270 |
return args |
| 271 |
} |
| 272 |
|
| 273 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 274 |
func (_q *DsseQuery) CollectFields(ctx context.Context, satisfies ...string) (*DsseQuery, error) { |
| 275 |
fc := graphql.GetFieldContext(ctx) |
| 276 |
if fc == nil { |
| 277 |
return _q, nil |
| 278 |
} |
| 279 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 280 |
return nil, err |
| 281 |
} |
| 282 |
return _q, nil |
| 283 |
} |
| 284 |
|
| 285 |
func (_q *DsseQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 286 |
path = append([]string(nil), path...) |
| 287 |
var ( |
| 288 |
unknownSeen bool |
| 289 |
fieldSeen = make(map[string]struct{}, len(dsse.Columns)) |
| 290 |
selectedFields = []string{dsse.FieldID} |
| 291 |
) |
| 292 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 293 |
switch field.Name { |
| 294 |
|
| 295 |
case "statement": |
| 296 |
var ( |
| 297 |
alias = field.Alias |
| 298 |
path = append(path, alias) |
| 299 |
query = (&StatementClient{config: _q.config}).Query() |
| 300 |
) |
| 301 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { |
| 302 |
return err |
| 303 |
} |
| 304 |
_q.withStatement = query |
| 305 |
|
| 306 |
case "signatures": |
| 307 |
var ( |
| 308 |
alias = field.Alias |
| 309 |
path = append(path, alias) |
| 310 |
query = (&SignatureClient{config: _q.config}).Query() |
| 311 |
) |
| 312 |
if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, signatureImplementors)...); err != nil { |
| 313 |
return err |
| 314 |
} |
| 315 |
_q.WithNamedSignatures(alias, func(wq *SignatureQuery) { |
| 316 |
*wq = *query |
| 317 |
}) |
| 318 |
|
| 319 |
case "payloadDigests": |
| 320 |
var ( |
| 321 |
alias = field.Alias |
| 322 |
path = append(path, alias) |
| 323 |
query = (&PayloadDigestClient{config: _q.config}).Query() |
| 324 |
) |
| 325 |
if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, payloaddigestImplementors)...); err != nil { |
| 326 |
return err |
| 327 |
} |
| 328 |
_q.WithNamedPayloadDigests(alias, func(wq *PayloadDigestQuery) { |
| 329 |
*wq = *query |
| 330 |
}) |
| 331 |
case "createdAt": |
| 332 |
if _, ok := fieldSeen[dsse.FieldCreatedAt]; !ok { |
| 333 |
selectedFields = append(selectedFields, dsse.FieldCreatedAt) |
| 334 |
fieldSeen[dsse.FieldCreatedAt] = struct{}{} |
| 335 |
} |
| 336 |
case "gitoidSha256": |
| 337 |
if _, ok := fieldSeen[dsse.FieldGitoidSha256]; !ok { |
| 338 |
selectedFields = append(selectedFields, dsse.FieldGitoidSha256) |
| 339 |
fieldSeen[dsse.FieldGitoidSha256] = struct{}{} |
| 340 |
} |
| 341 |
case "payloadType": |
| 342 |
if _, ok := fieldSeen[dsse.FieldPayloadType]; !ok { |
| 343 |
selectedFields = append(selectedFields, dsse.FieldPayloadType) |
| 344 |
fieldSeen[dsse.FieldPayloadType] = struct{}{} |
| 345 |
} |
| 346 |
case "id": |
| 347 |
case "__typename": |
| 348 |
default: |
| 349 |
unknownSeen = true |
| 350 |
} |
| 351 |
} |
| 352 |
if !unknownSeen { |
| 353 |
_q.Select(selectedFields...) |
| 354 |
} |
| 355 |
return nil |
| 356 |
} |
| 357 |
|
| 358 |
type dssePaginateArgs struct { |
| 359 |
first, last *int |
| 360 |
after, before *Cursor |
| 361 |
opts []DssePaginateOption |
| 362 |
} |
| 363 |
|
| 364 |
func newDssePaginateArgs(rv map[string]any) *dssePaginateArgs { |
| 365 |
args := &dssePaginateArgs{} |
| 366 |
if rv == nil { |
| 367 |
return args |
| 368 |
} |
| 369 |
if v := rv[firstField]; v != nil { |
| 370 |
args.first = v.(*int) |
| 371 |
} |
| 372 |
if v := rv[lastField]; v != nil { |
| 373 |
args.last = v.(*int) |
| 374 |
} |
| 375 |
if v := rv[afterField]; v != nil { |
| 376 |
args.after = v.(*Cursor) |
| 377 |
} |
| 378 |
if v := rv[beforeField]; v != nil { |
| 379 |
args.before = v.(*Cursor) |
| 380 |
} |
| 381 |
if v, ok := rv[orderByField]; ok { |
| 382 |
switch v := v.(type) { |
| 383 |
case map[string]any: |
| 384 |
var ( |
| 385 |
err1, err2 error |
| 386 |
order = &DsseOrder{Field: &DsseOrderField{}, Direction: entgql.OrderDirectionAsc} |
| 387 |
) |
| 388 |
if d, ok := v[directionField]; ok { |
| 389 |
err1 = order.Direction.UnmarshalGQL(d) |
| 390 |
} |
| 391 |
if f, ok := v[fieldField]; ok { |
| 392 |
err2 = order.Field.UnmarshalGQL(f) |
| 393 |
} |
| 394 |
if err1 == nil && err2 == nil { |
| 395 |
args.opts = append(args.opts, WithDsseOrder(order)) |
| 396 |
} |
| 397 |
case *DsseOrder: |
| 398 |
if v != nil { |
| 399 |
args.opts = append(args.opts, WithDsseOrder(v)) |
| 400 |
} |
| 401 |
} |
| 402 |
} |
| 403 |
if v, ok := rv[whereField].(*DsseWhereInput); ok { |
| 404 |
args.opts = append(args.opts, WithDsseFilter(v.Filter)) |
| 405 |
} |
| 406 |
return args |
| 407 |
} |
| 408 |
|
| 409 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 410 |
func (_q *PayloadDigestQuery) CollectFields(ctx context.Context, satisfies ...string) (*PayloadDigestQuery, error) { |
| 411 |
fc := graphql.GetFieldContext(ctx) |
| 412 |
if fc == nil { |
| 413 |
return _q, nil |
| 414 |
} |
| 415 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 416 |
return nil, err |
| 417 |
} |
| 418 |
return _q, nil |
| 419 |
} |
| 420 |
|
| 421 |
func (_q *PayloadDigestQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 422 |
path = append([]string(nil), path...) |
| 423 |
var ( |
| 424 |
unknownSeen bool |
| 425 |
fieldSeen = make(map[string]struct{}, len(payloaddigest.Columns)) |
| 426 |
selectedFields = []string{payloaddigest.FieldID} |
| 427 |
) |
| 428 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 429 |
switch field.Name { |
| 430 |
|
| 431 |
case "dsse": |
| 432 |
var ( |
| 433 |
alias = field.Alias |
| 434 |
path = append(path, alias) |
| 435 |
query = (&DsseClient{config: _q.config}).Query() |
| 436 |
) |
| 437 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { |
| 438 |
return err |
| 439 |
} |
| 440 |
_q.withDsse = query |
| 441 |
case "algorithm": |
| 442 |
if _, ok := fieldSeen[payloaddigest.FieldAlgorithm]; !ok { |
| 443 |
selectedFields = append(selectedFields, payloaddigest.FieldAlgorithm) |
| 444 |
fieldSeen[payloaddigest.FieldAlgorithm] = struct{}{} |
| 445 |
} |
| 446 |
case "value": |
| 447 |
if _, ok := fieldSeen[payloaddigest.FieldValue]; !ok { |
| 448 |
selectedFields = append(selectedFields, payloaddigest.FieldValue) |
| 449 |
fieldSeen[payloaddigest.FieldValue] = struct{}{} |
| 450 |
} |
| 451 |
case "id": |
| 452 |
case "__typename": |
| 453 |
default: |
| 454 |
unknownSeen = true |
| 455 |
} |
| 456 |
} |
| 457 |
if !unknownSeen { |
| 458 |
_q.Select(selectedFields...) |
| 459 |
} |
| 460 |
return nil |
| 461 |
} |
| 462 |
|
| 463 |
type payloaddigestPaginateArgs struct { |
| 464 |
first, last *int |
| 465 |
after, before *Cursor |
| 466 |
opts []PayloadDigestPaginateOption |
| 467 |
} |
| 468 |
|
| 469 |
func newPayloadDigestPaginateArgs(rv map[string]any) *payloaddigestPaginateArgs { |
| 470 |
args := &payloaddigestPaginateArgs{} |
| 471 |
if rv == nil { |
| 472 |
return args |
| 473 |
} |
| 474 |
if v := rv[firstField]; v != nil { |
| 475 |
args.first = v.(*int) |
| 476 |
} |
| 477 |
if v := rv[lastField]; v != nil { |
| 478 |
args.last = v.(*int) |
| 479 |
} |
| 480 |
if v := rv[afterField]; v != nil { |
| 481 |
args.after = v.(*Cursor) |
| 482 |
} |
| 483 |
if v := rv[beforeField]; v != nil { |
| 484 |
args.before = v.(*Cursor) |
| 485 |
} |
| 486 |
if v, ok := rv[whereField].(*PayloadDigestWhereInput); ok { |
| 487 |
args.opts = append(args.opts, WithPayloadDigestFilter(v.Filter)) |
| 488 |
} |
| 489 |
return args |
| 490 |
} |
| 491 |
|
| 492 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 493 |
func (_q *SignatureQuery) CollectFields(ctx context.Context, satisfies ...string) (*SignatureQuery, error) { |
| 494 |
fc := graphql.GetFieldContext(ctx) |
| 495 |
if fc == nil { |
| 496 |
return _q, nil |
| 497 |
} |
| 498 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 499 |
return nil, err |
| 500 |
} |
| 501 |
return _q, nil |
| 502 |
} |
| 503 |
|
| 504 |
func (_q *SignatureQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 505 |
path = append([]string(nil), path...) |
| 506 |
var ( |
| 507 |
unknownSeen bool |
| 508 |
fieldSeen = make(map[string]struct{}, len(signature.Columns)) |
| 509 |
selectedFields = []string{signature.FieldID} |
| 510 |
) |
| 511 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 512 |
switch field.Name { |
| 513 |
|
| 514 |
case "dsse": |
| 515 |
var ( |
| 516 |
alias = field.Alias |
| 517 |
path = append(path, alias) |
| 518 |
query = (&DsseClient{config: _q.config}).Query() |
| 519 |
) |
| 520 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { |
| 521 |
return err |
| 522 |
} |
| 523 |
_q.withDsse = query |
| 524 |
|
| 525 |
case "timestamps": |
| 526 |
var ( |
| 527 |
alias = field.Alias |
| 528 |
path = append(path, alias) |
| 529 |
query = (&TimestampClient{config: _q.config}).Query() |
| 530 |
) |
| 531 |
if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, timestampImplementors)...); err != nil { |
| 532 |
return err |
| 533 |
} |
| 534 |
_q.WithNamedTimestamps(alias, func(wq *TimestampQuery) { |
| 535 |
*wq = *query |
| 536 |
}) |
| 537 |
case "keyID": |
| 538 |
if _, ok := fieldSeen[signature.FieldKeyID]; !ok { |
| 539 |
selectedFields = append(selectedFields, signature.FieldKeyID) |
| 540 |
fieldSeen[signature.FieldKeyID] = struct{}{} |
| 541 |
} |
| 542 |
case "signature": |
| 543 |
if _, ok := fieldSeen[signature.FieldSignature]; !ok { |
| 544 |
selectedFields = append(selectedFields, signature.FieldSignature) |
| 545 |
fieldSeen[signature.FieldSignature] = struct{}{} |
| 546 |
} |
| 547 |
case "id": |
| 548 |
case "__typename": |
| 549 |
default: |
| 550 |
unknownSeen = true |
| 551 |
} |
| 552 |
} |
| 553 |
if !unknownSeen { |
| 554 |
_q.Select(selectedFields...) |
| 555 |
} |
| 556 |
return nil |
| 557 |
} |
| 558 |
|
| 559 |
type signaturePaginateArgs struct { |
| 560 |
first, last *int |
| 561 |
after, before *Cursor |
| 562 |
opts []SignaturePaginateOption |
| 563 |
} |
| 564 |
|
| 565 |
func newSignaturePaginateArgs(rv map[string]any) *signaturePaginateArgs { |
| 566 |
args := &signaturePaginateArgs{} |
| 567 |
if rv == nil { |
| 568 |
return args |
| 569 |
} |
| 570 |
if v := rv[firstField]; v != nil { |
| 571 |
args.first = v.(*int) |
| 572 |
} |
| 573 |
if v := rv[lastField]; v != nil { |
| 574 |
args.last = v.(*int) |
| 575 |
} |
| 576 |
if v := rv[afterField]; v != nil { |
| 577 |
args.after = v.(*Cursor) |
| 578 |
} |
| 579 |
if v := rv[beforeField]; v != nil { |
| 580 |
args.before = v.(*Cursor) |
| 581 |
} |
| 582 |
if v, ok := rv[whereField].(*SignatureWhereInput); ok { |
| 583 |
args.opts = append(args.opts, WithSignatureFilter(v.Filter)) |
| 584 |
} |
| 585 |
return args |
| 586 |
} |
| 587 |
|
| 588 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 589 |
func (_q *StatementQuery) CollectFields(ctx context.Context, satisfies ...string) (*StatementQuery, error) { |
| 590 |
fc := graphql.GetFieldContext(ctx) |
| 591 |
if fc == nil { |
| 592 |
return _q, nil |
| 593 |
} |
| 594 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 595 |
return nil, err |
| 596 |
} |
| 597 |
return _q, nil |
| 598 |
} |
| 599 |
|
| 600 |
func (_q *StatementQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 601 |
path = append([]string(nil), path...) |
| 602 |
var ( |
| 603 |
unknownSeen bool |
| 604 |
fieldSeen = make(map[string]struct{}, len(statement.Columns)) |
| 605 |
selectedFields = []string{statement.FieldID} |
| 606 |
) |
| 607 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 608 |
switch field.Name { |
| 609 |
|
| 610 |
case "subjects": |
| 611 |
var ( |
| 612 |
alias = field.Alias |
| 613 |
path = append(path, alias) |
| 614 |
query = (&SubjectClient{config: _q.config}).Query() |
| 615 |
) |
| 616 |
args := newSubjectPaginateArgs(fieldArgs(ctx, new(SubjectWhereInput), path...)) |
| 617 |
if err := validateFirstLast(args.first, args.last); err != nil { |
| 618 |
return fmt.Errorf("validate first and last in path %q: %w", path, err) |
| 619 |
} |
| 620 |
pager, err := newSubjectPager(args.opts, args.last != nil) |
| 621 |
if err != nil { |
| 622 |
return fmt.Errorf("create new pager in path %q: %w", path, err) |
| 623 |
} |
| 624 |
if query, err = pager.applyFilter(query); err != nil { |
| 625 |
return err |
| 626 |
} |
| 627 |
ignoredEdges := !hasCollectedField(ctx, append(path, edgesField)...) |
| 628 |
if hasCollectedField(ctx, append(path, totalCountField)...) || hasCollectedField(ctx, append(path, pageInfoField)...) { |
| 629 |
hasPagination := args.after != nil || args.first != nil || args.before != nil || args.last != nil |
| 630 |
if hasPagination || ignoredEdges { |
| 631 |
query := query.Clone() |
| 632 |
_q.loadTotal = append(_q.loadTotal, func(ctx context.Context, nodes []*Statement) error { |
| 633 |
ids := make([]driver.Value, len(nodes)) |
| 634 |
for i := range nodes { |
| 635 |
ids[i] = nodes[i].ID |
| 636 |
} |
| 637 |
var v []struct { |
| 638 |
NodeID uuid.UUID `sql:"statement_subjects"` |
| 639 |
Count int `sql:"count"` |
| 640 |
} |
| 641 |
query.Where(func(s *sql.Selector) { |
| 642 |
s.Where(sql.InValues(s.C(statement.SubjectsColumn), ids...)) |
| 643 |
}) |
| 644 |
if err := query.GroupBy(statement.SubjectsColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { |
| 645 |
return err |
| 646 |
} |
| 647 |
m := make(map[uuid.UUID]int, len(v)) |
| 648 |
for i := range v { |
| 649 |
m[v[i].NodeID] = v[i].Count |
| 650 |
} |
| 651 |
for i := range nodes { |
| 652 |
n := m[nodes[i].ID] |
| 653 |
if nodes[i].Edges.totalCount[0] == nil { |
| 654 |
nodes[i].Edges.totalCount[0] = make(map[string]int) |
| 655 |
} |
| 656 |
nodes[i].Edges.totalCount[0][alias] = n |
| 657 |
} |
| 658 |
return nil |
| 659 |
}) |
| 660 |
} else { |
| 661 |
_q.loadTotal = append(_q.loadTotal, func(_ context.Context, nodes []*Statement) error { |
| 662 |
for i := range nodes { |
| 663 |
n := len(nodes[i].Edges.Subjects) |
| 664 |
if nodes[i].Edges.totalCount[0] == nil { |
| 665 |
nodes[i].Edges.totalCount[0] = make(map[string]int) |
| 666 |
} |
| 667 |
nodes[i].Edges.totalCount[0][alias] = n |
| 668 |
} |
| 669 |
return nil |
| 670 |
}) |
| 671 |
} |
| 672 |
} |
| 673 |
if ignoredEdges || (args.first != nil && *args.first == 0) || (args.last != nil && *args.last == 0) { |
| 674 |
continue |
| 675 |
} |
| 676 |
if query, err = pager.applyCursors(query, args.after, args.before); err != nil { |
| 677 |
return err |
| 678 |
} |
| 679 |
path = append(path, edgesField, nodeField) |
| 680 |
if field := collectedField(ctx, path...); field != nil { |
| 681 |
if err := query.collectField(ctx, false, opCtx, *field, path, mayAddCondition(satisfies, subjectImplementors)...); err != nil { |
| 682 |
return err |
| 683 |
} |
| 684 |
} |
| 685 |
if limit := paginateLimit(args.first, args.last); limit > 0 { |
| 686 |
if oneNode { |
| 687 |
pager.applyOrder(query.Limit(limit)) |
| 688 |
} else { |
| 689 |
modify := entgql.LimitPerRow(statement.SubjectsColumn, limit, pager.orderExpr(query)) |
| 690 |
query.modifiers = append(query.modifiers, modify) |
| 691 |
} |
| 692 |
} else { |
| 693 |
query = pager.applyOrder(query) |
| 694 |
} |
| 695 |
_q.WithNamedSubjects(alias, func(wq *SubjectQuery) { |
| 696 |
*wq = *query |
| 697 |
}) |
| 698 |
|
| 699 |
case "policy": |
| 700 |
var ( |
| 701 |
alias = field.Alias |
| 702 |
path = append(path, alias) |
| 703 |
query = (&AttestationPolicyClient{config: _q.config}).Query() |
| 704 |
) |
| 705 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationpolicyImplementors)...); err != nil { |
| 706 |
return err |
| 707 |
} |
| 708 |
_q.withPolicy = query |
| 709 |
|
| 710 |
case "attestationCollections": |
| 711 |
var ( |
| 712 |
alias = field.Alias |
| 713 |
path = append(path, alias) |
| 714 |
query = (&AttestationCollectionClient{config: _q.config}).Query() |
| 715 |
) |
| 716 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationcollectionImplementors)...); err != nil { |
| 717 |
return err |
| 718 |
} |
| 719 |
_q.withAttestationCollections = query |
| 720 |
|
| 721 |
case "dsse": |
| 722 |
var ( |
| 723 |
alias = field.Alias |
| 724 |
path = append(path, alias) |
| 725 |
query = (&DsseClient{config: _q.config}).Query() |
| 726 |
) |
| 727 |
if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { |
| 728 |
return err |
| 729 |
} |
| 730 |
_q.WithNamedDsse(alias, func(wq *DsseQuery) { |
| 731 |
*wq = *query |
| 732 |
}) |
| 733 |
case "predicate": |
| 734 |
if _, ok := fieldSeen[statement.FieldPredicate]; !ok { |
| 735 |
selectedFields = append(selectedFields, statement.FieldPredicate) |
| 736 |
fieldSeen[statement.FieldPredicate] = struct{}{} |
| 737 |
} |
| 738 |
case "id": |
| 739 |
case "__typename": |
| 740 |
default: |
| 741 |
unknownSeen = true |
| 742 |
} |
| 743 |
} |
| 744 |
if !unknownSeen { |
| 745 |
_q.Select(selectedFields...) |
| 746 |
} |
| 747 |
return nil |
| 748 |
} |
| 749 |
|
| 750 |
type statementPaginateArgs struct { |
| 751 |
first, last *int |
| 752 |
after, before *Cursor |
| 753 |
opts []StatementPaginateOption |
| 754 |
} |
| 755 |
|
| 756 |
func newStatementPaginateArgs(rv map[string]any) *statementPaginateArgs { |
| 757 |
args := &statementPaginateArgs{} |
| 758 |
if rv == nil { |
| 759 |
return args |
| 760 |
} |
| 761 |
if v := rv[firstField]; v != nil { |
| 762 |
args.first = v.(*int) |
| 763 |
} |
| 764 |
if v := rv[lastField]; v != nil { |
| 765 |
args.last = v.(*int) |
| 766 |
} |
| 767 |
if v := rv[afterField]; v != nil { |
| 768 |
args.after = v.(*Cursor) |
| 769 |
} |
| 770 |
if v := rv[beforeField]; v != nil { |
| 771 |
args.before = v.(*Cursor) |
| 772 |
} |
| 773 |
if v, ok := rv[whereField].(*StatementWhereInput); ok { |
| 774 |
args.opts = append(args.opts, WithStatementFilter(v.Filter)) |
| 775 |
} |
| 776 |
return args |
| 777 |
} |
| 778 |
|
| 779 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 780 |
func (_q *SubjectQuery) CollectFields(ctx context.Context, satisfies ...string) (*SubjectQuery, error) { |
| 781 |
fc := graphql.GetFieldContext(ctx) |
| 782 |
if fc == nil { |
| 783 |
return _q, nil |
| 784 |
} |
| 785 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 786 |
return nil, err |
| 787 |
} |
| 788 |
return _q, nil |
| 789 |
} |
| 790 |
|
| 791 |
func (_q *SubjectQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 792 |
path = append([]string(nil), path...) |
| 793 |
var ( |
| 794 |
unknownSeen bool |
| 795 |
fieldSeen = make(map[string]struct{}, len(subject.Columns)) |
| 796 |
selectedFields = []string{subject.FieldID} |
| 797 |
) |
| 798 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 799 |
switch field.Name { |
| 800 |
|
| 801 |
case "subjectDigests": |
| 802 |
var ( |
| 803 |
alias = field.Alias |
| 804 |
path = append(path, alias) |
| 805 |
query = (&SubjectDigestClient{config: _q.config}).Query() |
| 806 |
) |
| 807 |
if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, subjectdigestImplementors)...); err != nil { |
| 808 |
return err |
| 809 |
} |
| 810 |
_q.WithNamedSubjectDigests(alias, func(wq *SubjectDigestQuery) { |
| 811 |
*wq = *query |
| 812 |
}) |
| 813 |
|
| 814 |
case "statement": |
| 815 |
var ( |
| 816 |
alias = field.Alias |
| 817 |
path = append(path, alias) |
| 818 |
query = (&StatementClient{config: _q.config}).Query() |
| 819 |
) |
| 820 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { |
| 821 |
return err |
| 822 |
} |
| 823 |
_q.withStatement = query |
| 824 |
case "createdAt": |
| 825 |
if _, ok := fieldSeen[subject.FieldCreatedAt]; !ok { |
| 826 |
selectedFields = append(selectedFields, subject.FieldCreatedAt) |
| 827 |
fieldSeen[subject.FieldCreatedAt] = struct{}{} |
| 828 |
} |
| 829 |
case "name": |
| 830 |
if _, ok := fieldSeen[subject.FieldName]; !ok { |
| 831 |
selectedFields = append(selectedFields, subject.FieldName) |
| 832 |
fieldSeen[subject.FieldName] = struct{}{} |
| 833 |
} |
| 834 |
case "id": |
| 835 |
case "__typename": |
| 836 |
default: |
| 837 |
unknownSeen = true |
| 838 |
} |
| 839 |
} |
| 840 |
if !unknownSeen { |
| 841 |
_q.Select(selectedFields...) |
| 842 |
} |
| 843 |
return nil |
| 844 |
} |
| 845 |
|
| 846 |
type subjectPaginateArgs struct { |
| 847 |
first, last *int |
| 848 |
after, before *Cursor |
| 849 |
opts []SubjectPaginateOption |
| 850 |
} |
| 851 |
|
| 852 |
func newSubjectPaginateArgs(rv map[string]any) *subjectPaginateArgs { |
| 853 |
args := &subjectPaginateArgs{} |
| 854 |
if rv == nil { |
| 855 |
return args |
| 856 |
} |
| 857 |
if v := rv[firstField]; v != nil { |
| 858 |
args.first = v.(*int) |
| 859 |
} |
| 860 |
if v := rv[lastField]; v != nil { |
| 861 |
args.last = v.(*int) |
| 862 |
} |
| 863 |
if v := rv[afterField]; v != nil { |
| 864 |
args.after = v.(*Cursor) |
| 865 |
} |
| 866 |
if v := rv[beforeField]; v != nil { |
| 867 |
args.before = v.(*Cursor) |
| 868 |
} |
| 869 |
if v, ok := rv[orderByField]; ok { |
| 870 |
switch v := v.(type) { |
| 871 |
case map[string]any: |
| 872 |
var ( |
| 873 |
err1, err2 error |
| 874 |
order = &SubjectOrder{Field: &SubjectOrderField{}, Direction: entgql.OrderDirectionAsc} |
| 875 |
) |
| 876 |
if d, ok := v[directionField]; ok { |
| 877 |
err1 = order.Direction.UnmarshalGQL(d) |
| 878 |
} |
| 879 |
if f, ok := v[fieldField]; ok { |
| 880 |
err2 = order.Field.UnmarshalGQL(f) |
| 881 |
} |
| 882 |
if err1 == nil && err2 == nil { |
| 883 |
args.opts = append(args.opts, WithSubjectOrder(order)) |
| 884 |
} |
| 885 |
case *SubjectOrder: |
| 886 |
if v != nil { |
| 887 |
args.opts = append(args.opts, WithSubjectOrder(v)) |
| 888 |
} |
| 889 |
} |
| 890 |
} |
| 891 |
if v, ok := rv[whereField].(*SubjectWhereInput); ok { |
| 892 |
args.opts = append(args.opts, WithSubjectFilter(v.Filter)) |
| 893 |
} |
| 894 |
return args |
| 895 |
} |
| 896 |
|
| 897 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 898 |
func (_q *SubjectDigestQuery) CollectFields(ctx context.Context, satisfies ...string) (*SubjectDigestQuery, error) { |
| 899 |
fc := graphql.GetFieldContext(ctx) |
| 900 |
if fc == nil { |
| 901 |
return _q, nil |
| 902 |
} |
| 903 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 904 |
return nil, err |
| 905 |
} |
| 906 |
return _q, nil |
| 907 |
} |
| 908 |
|
| 909 |
func (_q *SubjectDigestQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 910 |
path = append([]string(nil), path...) |
| 911 |
var ( |
| 912 |
unknownSeen bool |
| 913 |
fieldSeen = make(map[string]struct{}, len(subjectdigest.Columns)) |
| 914 |
selectedFields = []string{subjectdigest.FieldID} |
| 915 |
) |
| 916 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 917 |
switch field.Name { |
| 918 |
|
| 919 |
case "subject": |
| 920 |
var ( |
| 921 |
alias = field.Alias |
| 922 |
path = append(path, alias) |
| 923 |
query = (&SubjectClient{config: _q.config}).Query() |
| 924 |
) |
| 925 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, subjectImplementors)...); err != nil { |
| 926 |
return err |
| 927 |
} |
| 928 |
_q.withSubject = query |
| 929 |
case "algorithm": |
| 930 |
if _, ok := fieldSeen[subjectdigest.FieldAlgorithm]; !ok { |
| 931 |
selectedFields = append(selectedFields, subjectdigest.FieldAlgorithm) |
| 932 |
fieldSeen[subjectdigest.FieldAlgorithm] = struct{}{} |
| 933 |
} |
| 934 |
case "value": |
| 935 |
if _, ok := fieldSeen[subjectdigest.FieldValue]; !ok { |
| 936 |
selectedFields = append(selectedFields, subjectdigest.FieldValue) |
| 937 |
fieldSeen[subjectdigest.FieldValue] = struct{}{} |
| 938 |
} |
| 939 |
case "id": |
| 940 |
case "__typename": |
| 941 |
default: |
| 942 |
unknownSeen = true |
| 943 |
} |
| 944 |
} |
| 945 |
if !unknownSeen { |
| 946 |
_q.Select(selectedFields...) |
| 947 |
} |
| 948 |
return nil |
| 949 |
} |
| 950 |
|
| 951 |
type subjectdigestPaginateArgs struct { |
| 952 |
first, last *int |
| 953 |
after, before *Cursor |
| 954 |
opts []SubjectDigestPaginateOption |
| 955 |
} |
| 956 |
|
| 957 |
func newSubjectDigestPaginateArgs(rv map[string]any) *subjectdigestPaginateArgs { |
| 958 |
args := &subjectdigestPaginateArgs{} |
| 959 |
if rv == nil { |
| 960 |
return args |
| 961 |
} |
| 962 |
if v := rv[firstField]; v != nil { |
| 963 |
args.first = v.(*int) |
| 964 |
} |
| 965 |
if v := rv[lastField]; v != nil { |
| 966 |
args.last = v.(*int) |
| 967 |
} |
| 968 |
if v := rv[afterField]; v != nil { |
| 969 |
args.after = v.(*Cursor) |
| 970 |
} |
| 971 |
if v := rv[beforeField]; v != nil { |
| 972 |
args.before = v.(*Cursor) |
| 973 |
} |
| 974 |
if v, ok := rv[whereField].(*SubjectDigestWhereInput); ok { |
| 975 |
args.opts = append(args.opts, WithSubjectDigestFilter(v.Filter)) |
| 976 |
} |
| 977 |
return args |
| 978 |
} |
| 979 |
|
| 980 |
// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. |
| 981 |
func (_q *TimestampQuery) CollectFields(ctx context.Context, satisfies ...string) (*TimestampQuery, error) { |
| 982 |
fc := graphql.GetFieldContext(ctx) |
| 983 |
if fc == nil { |
| 984 |
return _q, nil |
| 985 |
} |
| 986 |
if err := _q.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { |
| 987 |
return nil, err |
| 988 |
} |
| 989 |
return _q, nil |
| 990 |
} |
| 991 |
|
| 992 |
func (_q *TimestampQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { |
| 993 |
path = append([]string(nil), path...) |
| 994 |
var ( |
| 995 |
unknownSeen bool |
| 996 |
fieldSeen = make(map[string]struct{}, len(timestamp.Columns)) |
| 997 |
selectedFields = []string{timestamp.FieldID} |
| 998 |
) |
| 999 |
for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { |
| 1000 |
switch field.Name { |
| 1001 |
|
| 1002 |
case "signature": |
| 1003 |
var ( |
| 1004 |
alias = field.Alias |
| 1005 |
path = append(path, alias) |
| 1006 |
query = (&SignatureClient{config: _q.config}).Query() |
| 1007 |
) |
| 1008 |
if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, signatureImplementors)...); err != nil { |
| 1009 |
return err |
| 1010 |
} |
| 1011 |
_q.withSignature = query |
| 1012 |
case "type": |
| 1013 |
if _, ok := fieldSeen[timestamp.FieldType]; !ok { |
| 1014 |
selectedFields = append(selectedFields, timestamp.FieldType) |
| 1015 |
fieldSeen[timestamp.FieldType] = struct{}{} |
| 1016 |
} |
| 1017 |
case "timestamp": |
| 1018 |
if _, ok := fieldSeen[timestamp.FieldTimestamp]; !ok { |
| 1019 |
selectedFields = append(selectedFields, timestamp.FieldTimestamp) |
| 1020 |
fieldSeen[timestamp.FieldTimestamp] = struct{}{} |
| 1021 |
} |
| 1022 |
case "id": |
| 1023 |
case "__typename": |
| 1024 |
default: |
| 1025 |
unknownSeen = true |
| 1026 |
} |
| 1027 |
} |
| 1028 |
if !unknownSeen { |
| 1029 |
_q.Select(selectedFields...) |
| 1030 |
} |
| 1031 |
return nil |
| 1032 |
} |
| 1033 |
|
| 1034 |
type timestampPaginateArgs struct { |
| 1035 |
first, last *int |
| 1036 |
after, before *Cursor |
| 1037 |
opts []TimestampPaginateOption |
| 1038 |
} |
| 1039 |
|
| 1040 |
func newTimestampPaginateArgs(rv map[string]any) *timestampPaginateArgs { |
| 1041 |
args := ×tampPaginateArgs{} |
| 1042 |
if rv == nil { |
| 1043 |
return args |
| 1044 |
} |
| 1045 |
if v := rv[firstField]; v != nil { |
| 1046 |
args.first = v.(*int) |
| 1047 |
} |
| 1048 |
if v := rv[lastField]; v != nil { |
| 1049 |
args.last = v.(*int) |
| 1050 |
} |
| 1051 |
if v := rv[afterField]; v != nil { |
| 1052 |
args.after = v.(*Cursor) |
| 1053 |
} |
| 1054 |
if v := rv[beforeField]; v != nil { |
| 1055 |
args.before = v.(*Cursor) |
| 1056 |
} |
| 1057 |
if v, ok := rv[whereField].(*TimestampWhereInput); ok { |
| 1058 |
args.opts = append(args.opts, WithTimestampFilter(v.Filter)) |
| 1059 |
} |
| 1060 |
return args |
| 1061 |
} |
| 1062 |
|
| 1063 |
const ( |
| 1064 |
afterField = "after" |
| 1065 |
firstField = "first" |
| 1066 |
beforeField = "before" |
| 1067 |
lastField = "last" |
| 1068 |
orderByField = "orderBy" |
| 1069 |
directionField = "direction" |
| 1070 |
fieldField = "field" |
| 1071 |
whereField = "where" |
| 1072 |
) |
| 1073 |
|
| 1074 |
func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { |
| 1075 |
field := collectedField(ctx, path...) |
| 1076 |
if field == nil || field.Arguments == nil { |
| 1077 |
return nil |
| 1078 |
} |
| 1079 |
oc := graphql.GetOperationContext(ctx) |
| 1080 |
args := field.ArgumentMap(oc.Variables) |
| 1081 |
return unmarshalArgs(ctx, whereInput, args) |
| 1082 |
} |
| 1083 |
|
| 1084 |
// unmarshalArgs allows extracting the field arguments from their raw representation. |
| 1085 |
func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { |
| 1086 |
for _, k := range []string{firstField, lastField} { |
| 1087 |
v, ok := args[k] |
| 1088 |
if !ok || v == nil { |
| 1089 |
continue |
| 1090 |
} |
| 1091 |
i, err := graphql.UnmarshalInt(v) |
| 1092 |
if err == nil { |
| 1093 |
args[k] = &i |
| 1094 |
} |
| 1095 |
} |
| 1096 |
for _, k := range []string{beforeField, afterField} { |
| 1097 |
v, ok := args[k] |
| 1098 |
if !ok { |
| 1099 |
continue |
| 1100 |
} |
| 1101 |
c := &Cursor{} |
| 1102 |
if c.UnmarshalGQL(v) == nil { |
| 1103 |
args[k] = c |
| 1104 |
} |
| 1105 |
} |
| 1106 |
if v, ok := args[whereField]; ok && whereInput != nil { |
| 1107 |
if err := graphql.UnmarshalInputFromContext(ctx, v, whereInput); err == nil { |
| 1108 |
args[whereField] = whereInput |
| 1109 |
} |
| 1110 |
} |
| 1111 |
|
| 1112 |
return args |
| 1113 |
} |
| 1114 |
|
| 1115 |
// mayAddCondition appends another type condition to the satisfies list |
| 1116 |
// if it does not exist in the list. |
| 1117 |
func mayAddCondition(satisfies []string, typeCond []string) []string { |
| 1118 |
Cond: |
| 1119 |
for _, c := range typeCond { |
| 1120 |
for _, s := range satisfies { |
| 1121 |
if c == s { |
| 1122 |
continue Cond |
| 1123 |
} |
| 1124 |
} |
| 1125 |
satisfies = append(satisfies, c) |
| 1126 |
} |
| 1127 |
return satisfies |
| 1128 |
} |