Module: CardDB::QueryBuilder

Defined in:
lib/carddb/query_builder.rb

Overview

Builds GraphQL queries for the CardDB API. rubocop:disable Metrics/ModuleLength

Constant Summary collapse

SCHEMA_NESTED_FIELDS_DEPTH =
4

Class Method Summary collapse

Class Method Details

.activate_ruleset_versionObject



1326
1327
1328
1329
1330
1331
1332
1333
1334
# File 'lib/carddb/query_builder.rb', line 1326

def activate_ruleset_version
  <<~GRAPHQL
    mutation RulesetVersionActivate($id: UUID!) {
      rulesetVersionActivate(id: $id) {
        #{ruleset_version_fields}
      }
    }
  GRAPHQL
end

.add_deck_entryObject



1423
1424
1425
1426
1427
1428
1429
1430
1431
# File 'lib/carddb/query_builder.rb', line 1423

def add_deck_entry
  <<~GRAPHQL
    mutation DeckEntryAdd($input: DeckEntryAddInput!) {
      deckEntryAdd(input: $input) {
        #{deck_entry_mutation_payload_fields}
      }
    }
  GRAPHQL
end

.app_decks(filter: nil, first: nil, after: nil) ⇒ Object



964
965
966
967
968
969
970
971
972
973
974
975
976
977
# File 'lib/carddb/query_builder.rb', line 964

def app_decks(filter: nil, first: nil, after: nil)
  args = build_args(
    { filter: filter, first: first, after: after },
    type_overrides: { filter: 'AppDecksFilterInput' }
  )

  <<~GRAPHQL
    query AppDecks#{args[:definition]} {
      appDecks#{args[:call]} {
        #{deck_connection_fields}
      }
    }
  GRAPHQL
end

.archive_deckObject



1567
1568
1569
1570
1571
1572
1573
1574
1575
# File 'lib/carddb/query_builder.rb', line 1567

def archive_deck
  <<~GRAPHQL
    mutation DeckArchive($id: UUID!) {
      deckArchive(id: $id) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.archive_deck_import_formatObject



1503
1504
1505
1506
1507
1508
1509
1510
1511
# File 'lib/carddb/query_builder.rb', line 1503

def archive_deck_import_format
  <<~GRAPHQL
    mutation DeckImportFormatArchive($id: UUID!) {
      deckImportFormatArchive(id: $id) {
        #{deck_import_format_definition_fields}
      }
    }
  GRAPHQL
end

.claim_deckObject



1537
1538
1539
1540
1541
1542
1543
1544
1545
# File 'lib/carddb/query_builder.rb', line 1537

def claim_deck
  <<~GRAPHQL
    mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
      deckClaim(id: $id, input: $input) {
        #{deck_ownership_transfer_payload_fields}
      }
    }
  GRAPHQL
end

.confirm_scan_uploadObject



729
730
731
732
733
734
735
736
737
# File 'lib/carddb/query_builder.rb', line 729

def confirm_scan_upload
  <<~GRAPHQL
    mutation ConfirmScanUpload($input: ConfirmScanUploadInput!) {
      confirmScanUpload(input: $input) {
        #{file_fields}
      }
    }
  GRAPHQL
end

.copy_deckObject



1557
1558
1559
1560
1561
1562
1563
1564
1565
# File 'lib/carddb/query_builder.rb', line 1557

def copy_deck
  <<~GRAPHQL
    mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
      deckCopy(id: $id, input: $input) {
        #{deck_copy_payload_fields}
      }
    }
  GRAPHQL
end

.create_deckObject

Builds a deckCreate mutation



1402
1403
1404
1405
1406
1407
1408
1409
1410
# File 'lib/carddb/query_builder.rb', line 1402

def create_deck
  <<~GRAPHQL
    mutation DeckCreate($input: DeckCreateInput!) {
      deckCreate(input: $input) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.create_deck_import_formatObject



1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'lib/carddb/query_builder.rb', line 1483

def create_deck_import_format
  <<~GRAPHQL
    mutation DeckImportFormatCreate($input: DeckImportFormatCreateInput!) {
      deckImportFormatCreate(input: $input) {
        #{deck_import_format_definition_fields}
      }
    }
  GRAPHQL
end

.create_deck_token_issuerObject



1638
1639
1640
1641
1642
1643
1644
1645
1646
# File 'lib/carddb/query_builder.rb', line 1638

def create_deck_token_issuer
  <<~GRAPHQL
    mutation DeckTokenIssuerCreate($input: DeckTokenIssuerCreateInput!) {
      deckTokenIssuerCreate(input: $input) {
        #{deck_token_issuer_fields}
      }
    }
  GRAPHQL
end

.create_gameObject



147
148
149
150
151
152
153
154
155
# File 'lib/carddb/query_builder.rb', line 147

def create_game
  <<~GRAPHQL
    mutation GameCreate($input: GameCreateInput!) {
      gameCreate(input: $input) {
        #{game_fields}
      }
    }
  GRAPHQL
end

.create_rulesetObject



1266
1267
1268
1269
1270
1271
1272
1273
1274
# File 'lib/carddb/query_builder.rb', line 1266

def create_ruleset
  <<~GRAPHQL
    mutation RulesetCreate($input: RulesetCreateInput!) {
      rulesetCreate(input: $input) {
        #{ruleset_fields}
      }
    }
  GRAPHQL
end

.create_ruleset_version_draftObject



1286
1287
1288
1289
1290
1291
1292
1293
1294
# File 'lib/carddb/query_builder.rb', line 1286

def create_ruleset_version_draft
  <<~GRAPHQL
    mutation RulesetVersionDraftCreate($rulesetId: UUID!, $input: RulesetVersionDraftCreateInput!) {
      rulesetVersionDraftCreate(rulesetId: $rulesetId, input: $input) {
        #{ruleset_version_fields}
      }
    }
  GRAPHQL
end

.create_scan_jobObject



739
740
741
742
743
744
745
746
747
748
749
750
# File 'lib/carddb/query_builder.rb', line 739

def create_scan_job
  <<~GRAPHQL
    mutation CreateScanJob($input: CreateScanJobInput!) {
      createScanJob(input: $input) {
        job {
          #{scan_job_fields}
        }
        created
      }
    }
  GRAPHQL
end

.create_scan_templateObject



817
818
819
820
821
822
823
824
825
826
827
828
829
830
# File 'lib/carddb/query_builder.rb', line 817

def create_scan_template
  <<~GRAPHQL
    mutation CreateScanTemplate($input: SaveScanTemplateInput!) {
      createScanTemplate(input: $input) {
        template {
          #{scan_template_fields}
        }
        warnings {
          #{scan_template_warning_fields}
        }
      }
    }
  GRAPHQL
end

.create_scan_upload_sessionObject



719
720
721
722
723
724
725
726
727
# File 'lib/carddb/query_builder.rb', line 719

def create_scan_upload_session
  <<~GRAPHQL
    mutation CreateScanUploadSession($input: CreateScanUploadSessionInput!) {
      createScanUploadSession(input: $input) {
        #{presigned_upload_fields}
      }
    }
  GRAPHQL
end

.dataset(id: nil, publisher_id: nil, game_id: nil, dataset_key: nil) ⇒ Object



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/carddb/query_builder.rb', line 287

def dataset(id: nil, publisher_id: nil, game_id: nil, dataset_key: nil)
  args = build_args(
    {
      id: id,
      publisherId: publisher_id,
      gameId: game_id,
      datasetKey: dataset_key
    }
  )

  <<~GRAPHQL
    query Dataset#{args[:definition]} {
      dataset#{args[:call]} {
        #{dataset_fields}
        #{schema_fields}
      }
    }
  GRAPHQL
end

.dataset_exportObject



906
907
908
909
910
911
912
913
914
# File 'lib/carddb/query_builder.rb', line 906

def dataset_export
  <<~GRAPHQL
    mutation DatasetExport($input: DatasetExportInput!) {
      datasetExport(input: $input) {
        #{export_job_fields}
      }
    }
  GRAPHQL
end

.dataset_filter_values(fields:, id: nil, publisher_slug: nil, game_key: nil, dataset_key: nil, search: nil, include_counts: nil, first: nil, after: nil) ⇒ Object

Raises:

  • (ArgumentError)


222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/carddb/query_builder.rb', line 222

def dataset_filter_values(
  fields:,
  id: nil,
  publisher_slug: nil,
  game_key: nil,
  dataset_key: nil,
  search: nil,
  include_counts: nil,
  first: nil,
  after: nil
)
  raise ArgumentError, 'fields must contain at least one field key' if fields.empty?

  dataset_lookup = dataset_filter_values_lookup(
    id: id,
    publisher_slug: publisher_slug,
    game_key: game_key,
    dataset_key: dataset_key
  )
  filter_params = { fields: fields, search: search, includeCounts: include_counts, first: first, after: after }.compact
  args = build_args(dataset_lookup.merge(filter_params), required: dataset_lookup.keys + [:fields])

  dataset_args = graphql_variable_calls(dataset_lookup.keys)
  filter_args = graphql_variable_calls(filter_params.keys)

  <<~GRAPHQL
    query FetchDatasetFilterValues#{args[:definition]} {
      fetchDataset(#{dataset_args}) {
        filterValues(#{filter_args}) {
          #{dataset_filter_value_connection_fields}
        }
      }
    }
  GRAPHQL
end

.dataset_import_from_fileObject



522
523
524
525
526
527
528
529
530
# File 'lib/carddb/query_builder.rb', line 522

def dataset_import_from_file
  <<~GRAPHQL
    mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
      datasetImportFromFile(input: $input) {
        #{import_job_fields}
      }
    }
  GRAPHQL
end

.dataset_import_from_payloadObject



532
533
534
535
536
537
538
539
540
# File 'lib/carddb/query_builder.rb', line 532

def dataset_import_from_payload
  <<~GRAPHQL
    mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
      datasetImportFromPayload(input: $input) {
        #{import_job_fields}
      }
    }
  GRAPHQL
end

.dataset_import_from_urlObject



542
543
544
545
546
547
548
549
550
# File 'lib/carddb/query_builder.rb', line 542

def dataset_import_from_url
  <<~GRAPHQL
    mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
      datasetImportFromUrl(input: $input) {
        #{import_job_fields}
      }
    }
  GRAPHQL
end

.dataset_import_previewObject



502
503
504
505
506
507
508
509
510
# File 'lib/carddb/query_builder.rb', line 502

def dataset_import_preview
  <<~GRAPHQL
    query DatasetImportPreview($input: DatasetImportPreviewInput!) {
      datasetImportPreview(input: $input) {
        #{dataset_import_preview_fields}
      }
    }
  GRAPHQL
end

.dataset_import_validateObject



512
513
514
515
516
517
518
519
520
# File 'lib/carddb/query_builder.rb', line 512

def dataset_import_validate
  <<~GRAPHQL
    query DatasetImportValidate($input: DatasetImportValidateInput!) {
      datasetImportValidate(input: $input) {
        #{bulk_import_result_fields}
      }
    }
  GRAPHQL
end

.dataset_record(**params) ⇒ Object



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/carddb/query_builder.rb', line 429

def dataset_record(**params)
  args = build_args(
    {
      id: params[:id],
      datasetId: params[:dataset_id],
      identifier: params[:identifier],
      publisherSlug: params[:publisher_slug],
      gameKey: params[:game_key],
      datasetKey: params[:dataset_key],
      recordId: params[:record_id],
      resolveLinks: params[:resolve_links],
      validateSchema: params[:validate_schema]
    }
  )
  include_links = params[:resolve_links]&.any?
  links_fields = resolved_links_fields if include_links

  <<~GRAPHQL
    query DatasetRecord#{args[:definition]} {
      datasetRecord#{args[:call]} {
        #{record_fields(include_pricing: params.fetch(:include_pricing, false))}
        #{links_fields}
      }
    }
  GRAPHQL
end

.dataset_record_delete_jobObject



476
477
478
479
480
481
482
483
484
# File 'lib/carddb/query_builder.rb', line 476

def dataset_record_delete_job
  <<~GRAPHQL
    query DatasetRecordDeleteJob($id: UUID!) {
      datasetRecordDeleteJob(id: $id) {
        #{dataset_record_delete_job_fields}
      }
    }
  GRAPHQL
end

.dataset_record_delete_jobs(publisher_id:, dataset_id: nil, status: nil, first: nil, after: nil) ⇒ Object



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/carddb/query_builder.rb', line 486

def dataset_record_delete_jobs(publisher_id:, dataset_id: nil, status: nil, first: nil, after: nil)
  args = build_args(
    { publisherId: publisher_id, datasetId: dataset_id, status: status, first: first, after: after },
    required: [:publisherId],
    type_overrides: { status: 'DatasetRecordDeleteJobStatus' }
  )

  <<~GRAPHQL
    query DatasetRecordDeleteJobs#{args[:definition]} {
      datasetRecordDeleteJobs#{args[:call]} {
        #{dataset_record_delete_job_connection_fields}
      }
    }
  GRAPHQL
end

.deckObject



1005
1006
1007
1008
1009
1010
1011
1012
1013
# File 'lib/carddb/query_builder.rb', line 1005

def deck
  <<~GRAPHQL
    query Deck($id: UUID!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
      deck(id: $id, readState: $readState, version: $version) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.deck_api_application_accessesObject



1347
1348
1349
1350
1351
1352
1353
1354
1355
# File 'lib/carddb/query_builder.rb', line 1347

def deck_api_application_accesses
  <<~GRAPHQL
    query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
      deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
        #{deck_api_application_access_fields}
      }
    }
  GRAPHQL
end

.deck_by_external_refObject



1058
1059
1060
1061
1062
1063
1064
1065
1066
# File 'lib/carddb/query_builder.rb', line 1058

def deck_by_external_ref
  <<~GRAPHQL
    query DeckByExternalRef($externalRef: String!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
      deckByExternalRef(externalRef: $externalRef, readState: $readState, version: $version) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.deck_by_slugObject



1037
1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/carddb/query_builder.rb', line 1037

def deck_by_slug
  <<~GRAPHQL
    query DeckBySlug($publisherSlug: String!, $gameKey: String!, $slug: String!) {
      deckBySlug(publisherSlug: $publisherSlug, gameKey: $gameKey, slug: $slug) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.deck_collaboratorsObject

Builds a deckCollaborators query



1337
1338
1339
1340
1341
1342
1343
1344
1345
# File 'lib/carddb/query_builder.rb', line 1337

def deck_collaborators
  <<~GRAPHQL
    query DeckCollaborators($deckId: UUID!) {
      deckCollaborators(deckId: $deckId) {
        #{deck_collaborator_fields}
      }
    }
  GRAPHQL
end

.deck_draft_diffObject



1092
1093
1094
1095
1096
1097
1098
1099
1100
# File 'lib/carddb/query_builder.rb', line 1092

def deck_draft_diff
  <<~GRAPHQL
    query DeckDraftDiff($id: UUID!) {
      deckDraftDiff(id: $id) {
        #{deck_diff_fields}
      }
    }
  GRAPHQL
end

.deck_exportObject



1122
1123
1124
1125
1126
1127
1128
1129
1130
# File 'lib/carddb/query_builder.rb', line 1122

def deck_export
  <<~GRAPHQL
    query DeckExport($id: UUID!, $format: DeckExportFormat!) {
      deckExport(id: $id, format: $format) {
        #{deck_export_payload_fields}
      }
    }
  GRAPHQL
end

.deck_hydrate_entriesObject



1112
1113
1114
1115
1116
1117
1118
1119
1120
# File 'lib/carddb/query_builder.rb', line 1112

def deck_hydrate_entries
  <<~GRAPHQL
    query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
      deckHydrateEntries(input: $input) {
        #{deck_hydrate_entries_payload_fields}
      }
    }
  GRAPHQL
end

.deck_import_formatObject



1381
1382
1383
1384
1385
1386
1387
1388
1389
# File 'lib/carddb/query_builder.rb', line 1381

def deck_import_format
  <<~GRAPHQL
    query DeckImportFormat($id: UUID, $gameId: UUID, $key: String) {
      deckImportFormat(id: $id, gameId: $gameId, key: $key) {
        #{deck_import_format_definition_fields}
      }
    }
  GRAPHQL
end

.deck_import_format_testObject



1391
1392
1393
1394
1395
1396
1397
1398
1399
# File 'lib/carddb/query_builder.rb', line 1391

def deck_import_format_test
  <<~GRAPHQL
    query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
      deckImportFormatTest(input: $input) {
        #{deck_import_format_test_payload_fields}
      }
    }
  GRAPHQL
end

.deck_import_formats(publisher_id: nil, game_id: nil, include_archived: nil, first: nil, after: nil) ⇒ Object



1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
# File 'lib/carddb/query_builder.rb', line 1367

def deck_import_formats(publisher_id: nil, game_id: nil, include_archived: nil, first: nil, after: nil)
  args = build_args(
    { publisherId: publisher_id, gameId: game_id, includeArchived: include_archived, first: first, after: after }
  )

  <<~GRAPHQL
    query DeckImportFormats#{args[:definition]} {
      deckImportFormats#{args[:call]} {
        #{deck_import_format_definition_connection_fields}
      }
    }
  GRAPHQL
end

.deck_section_definitions(publisher_slug: nil, game_key: nil, game_id: nil, ruleset_key: nil, ruleset_version_id: nil) ⇒ Object



1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'lib/carddb/query_builder.rb', line 1142

def deck_section_definitions(publisher_slug: nil, game_key: nil, game_id: nil, ruleset_key: nil, ruleset_version_id: nil)
  args = build_args({
                      publisherSlug: publisher_slug,
                      gameKey: game_key,
                      gameId: game_id,
                      rulesetKey: ruleset_key,
                      rulesetVersionId: ruleset_version_id
                    })

  <<~GRAPHQL
    query DeckSectionDefinitions#{args[:definition]} {
      deckSectionDefinitions#{args[:call]} {
        #{deck_section_definition_fields}
      }
    }
  GRAPHQL
end

.deck_validateObject



1132
1133
1134
1135
1136
1137
1138
1139
1140
# File 'lib/carddb/query_builder.rb', line 1132

def deck_validate
  <<~GRAPHQL
    query DeckValidate($id: UUID!, $input: DeckValidateInput) {
      deckValidate(id: $id, input: $input) {
        #{deck_validation_fields}
      }
    }
  GRAPHQL
end

.deck_validation_rulesObject



1231
1232
1233
1234
1235
1236
1237
1238
1239
# File 'lib/carddb/query_builder.rb', line 1231

def deck_validation_rules
  <<~GRAPHQL
    query DeckValidationRules($gameId: UUID!, $rulesetKey: String!, $rulesetVersionId: UUID) {
      deckValidationRules(gameId: $gameId, rulesetKey: $rulesetKey, rulesetVersionId: $rulesetVersionId) {
        #{deck_validation_rules_fields}
      }
    }
  GRAPHQL
end

.deck_versionObject

Builds a deckVersion query



1069
1070
1071
1072
1073
1074
1075
1076
1077
# File 'lib/carddb/query_builder.rb', line 1069

def deck_version
  <<~GRAPHQL
    query DeckVersion($id: UUID!) {
      deckVersion(id: $id) {
        #{deck_version_fields}
      }
    }
  GRAPHQL
end

.deck_version_diffObject



1102
1103
1104
1105
1106
1107
1108
1109
1110
# File 'lib/carddb/query_builder.rb', line 1102

def deck_version_diff
  <<~GRAPHQL
    query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
      deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
        #{deck_diff_fields}
      }
    }
  GRAPHQL
end

.deck_versions(first: nil, after: nil) ⇒ Object

Builds a deckVersions query



1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
# File 'lib/carddb/query_builder.rb', line 1080

def deck_versions(first: nil, after: nil)
  args = build_args({ deckId: true, first: first, after: after }, required: [:deckId])

  <<~GRAPHQL
    query DeckVersions#{args[:definition]} {
      deckVersions#{args[:call]} {
        #{deck_version_connection_fields}
      }
    }
  GRAPHQL
end

.delete_dataset_recordsObject



466
467
468
469
470
471
472
473
474
# File 'lib/carddb/query_builder.rb', line 466

def delete_dataset_records
  <<~GRAPHQL
    mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
      datasetRecordsDelete(input: $input) {
        #{dataset_record_delete_job_fields}
      }
    }
  GRAPHQL
end

.delete_deckObject

Builds a deckDelete mutation



1706
1707
1708
1709
1710
1711
1712
# File 'lib/carddb/query_builder.rb', line 1706

def delete_deck
  <<~GRAPHQL
    mutation DeckDelete($id: UUID!) {
      deckDelete(id: $id)
    }
  GRAPHQL
end

.exchange_deck_tokenObject



1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
# File 'lib/carddb/query_builder.rb', line 1666

def exchange_deck_token
  <<~GRAPHQL
    mutation DeckTokenExchange($input: DeckTokenExchangeInput!) {
      deckTokenExchange(input: $input) {
        token
        deckToken {
          #{deck_token_fields}
        }
      }
    }
  GRAPHQL
end

.export_jobObject



873
874
875
876
877
878
879
880
881
# File 'lib/carddb/query_builder.rb', line 873

def export_job
  <<~GRAPHQL
    query ExportJob($id: UUID!) {
      exportJob(id: $id) {
        #{export_job_fields}
      }
    }
  GRAPHQL
end

.export_job_cancelObject



916
917
918
919
920
921
922
923
924
# File 'lib/carddb/query_builder.rb', line 916

def export_job_cancel
  <<~GRAPHQL
    mutation ExportJobCancel($id: UUID!) {
      exportJobCancel(id: $id) {
        #{export_job_fields}
      }
    }
  GRAPHQL
end

.export_job_refresh_urlObject



926
927
928
929
930
931
932
933
934
# File 'lib/carddb/query_builder.rb', line 926

def export_job_refresh_url
  <<~GRAPHQL
    mutation ExportJobRefreshUrl($id: UUID!) {
      exportJobRefreshUrl(id: $id) {
        #{export_job_fields}
      }
    }
  GRAPHQL
end

.export_jobs(publisher_id:, game_id: nil, dataset_id: nil, status: nil, first: nil, after: nil) ⇒ Object



883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
# File 'lib/carddb/query_builder.rb', line 883

def export_jobs(publisher_id:, game_id: nil, dataset_id: nil, status: nil, first: nil, after: nil)
  args = build_args(
    {
      publisherId: publisher_id,
      gameId: game_id,
      datasetId: dataset_id,
      status: status,
      first: first,
      after: after
    },
    required: [:publisherId],
    type_overrides: { status: 'ExportJobStatus' }
  )

  <<~GRAPHQL
    query ExportJobs#{args[:definition]} {
      exportJobs#{args[:call]} {
        #{export_job_connection_fields}
      }
    }
  GRAPHQL
end

.fetch_dataset_by_idObject

Builds a fetchDataset query by id



188
189
190
191
192
193
194
195
196
197
# File 'lib/carddb/query_builder.rb', line 188

def fetch_dataset_by_id
  <<~GRAPHQL
    query FetchDataset($id: UUID!) {
      fetchDataset(id: $id) {
        #{dataset_fields}
        #{schema_fields}
      }
    }
  GRAPHQL
end

.fetch_dataset_by_keysObject

Builds a fetchDataset query by keys (includes schema)



200
201
202
203
204
205
206
207
208
209
# File 'lib/carddb/query_builder.rb', line 200

def fetch_dataset_by_keys
  <<~GRAPHQL
    query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
      fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
        #{dataset_fields}
        #{schema_fields}
      }
    }
  GRAPHQL
end

.fetch_datasetsObject

Builds a fetchDatasets batch query



212
213
214
215
216
217
218
219
220
# File 'lib/carddb/query_builder.rb', line 212

def fetch_datasets
  <<~GRAPHQL
    query FetchDatasets($ids: [UUID!]!) {
      fetchDatasets(ids: $ids) {
        #{dataset_fields}
      }
    }
  GRAPHQL
end

.fetch_deckObject

Builds a fetchDeck query



995
996
997
998
999
1000
1001
1002
1003
# File 'lib/carddb/query_builder.rb', line 995

def fetch_deck
  <<~GRAPHQL
    query FetchDeck($id: UUID!) {
      fetchDeck(id: $id) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.fetch_deck_by_external_refObject

Builds a fetchDeckByExternalRef query



1048
1049
1050
1051
1052
1053
1054
1055
1056
# File 'lib/carddb/query_builder.rb', line 1048

def fetch_deck_by_external_ref
  <<~GRAPHQL
    query FetchDeckByExternalRef($externalRef: String!) {
      fetchDeckByExternalRef(externalRef: $externalRef) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.fetch_deck_by_slugObject

Builds a fetchDeckBySlug query



1027
1028
1029
1030
1031
1032
1033
1034
1035
# File 'lib/carddb/query_builder.rb', line 1027

def fetch_deck_by_slug
  <<~GRAPHQL
    query FetchDeckBySlug($publisherSlug: String!, $gameKey: String!, $slug: String!) {
      fetchDeckBySlug(publisherSlug: $publisherSlug, gameKey: $gameKey, slug: $slug) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.fetch_game_by_idObject

Builds a fetchGame query by id



80
81
82
83
84
85
86
87
88
# File 'lib/carddb/query_builder.rb', line 80

def fetch_game_by_id
  <<~GRAPHQL
    query FetchGame($id: UUID!) {
      fetchGame(id: $id) {
        #{game_fields}
      }
    }
  GRAPHQL
end

.fetch_game_by_keysObject

Builds a fetchGame query by publisher slug and game key



91
92
93
94
95
96
97
98
99
# File 'lib/carddb/query_builder.rb', line 91

def fetch_game_by_keys
  <<~GRAPHQL
    query FetchGame($publisherSlug: String!, $gameKey: String!) {
      fetchGame(publisherSlug: $publisherSlug, gameKey: $gameKey) {
        #{game_fields}
      }
    }
  GRAPHQL
end

.fetch_gamesObject

Builds a fetchGames batch query



102
103
104
105
106
107
108
109
110
# File 'lib/carddb/query_builder.rb', line 102

def fetch_games
  <<~GRAPHQL
    query FetchGames($ids: [UUID!]!) {
      fetchGames(ids: $ids) {
        #{game_fields}
      }
    }
  GRAPHQL
end

.fetch_meObject

Builds a fetchMe query



1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
# File 'lib/carddb/query_builder.rb', line 1715

def fetch_me
  <<~GRAPHQL
    query FetchMe {
      fetchMe {
        application {
          id
          name
          description
          environment
          apiKeyPrefix
          allowedOrigins
          allowedIps
          createdAt
          updatedAt
          lastUsedAt
        }
        account {
          id
          displayName
          createdAt
        }
      }
    }
  GRAPHQL
end

.fetch_publisher_by_idObject

Builds a fetchPublisher query (by id or slug)



29
30
31
32
33
34
35
36
37
# File 'lib/carddb/query_builder.rb', line 29

def fetch_publisher_by_id
  <<~GRAPHQL
    query FetchPublisher($id: UUID!) {
      fetchPublisher(id: $id) {
        #{publisher_fields}
      }
    }
  GRAPHQL
end

.fetch_publisher_by_slugObject

Builds a fetchPublisher query by slug



40
41
42
43
44
45
46
47
48
# File 'lib/carddb/query_builder.rb', line 40

def fetch_publisher_by_slug
  <<~GRAPHQL
    query FetchPublisher($slug: String!) {
      fetchPublisher(slug: $slug) {
        #{publisher_fields}
      }
    }
  GRAPHQL
end

.fetch_publishersObject

Builds a fetchPublishers query



51
52
53
54
55
56
57
58
59
# File 'lib/carddb/query_builder.rb', line 51

def fetch_publishers
  <<~GRAPHQL
    query FetchPublishers($slugs: [String!]!) {
      fetchPublishers(slugs: $slugs) {
        #{publisher_fields}
      }
    }
  GRAPHQL
end

.fetch_record(include_pricing: false) ⇒ Object

Builds a fetchRecord query



374
375
376
377
378
379
380
381
382
# File 'lib/carddb/query_builder.rb', line 374

def fetch_record(include_pricing: false)
  <<~GRAPHQL
    query FetchRecord($id: UUID!) {
      fetchRecord(id: $id) {
        #{record_fields(include_pricing: include_pricing)}
      }
    }
  GRAPHQL
end

.fetch_record_by_identifier(include_pricing: false) ⇒ Object

Builds a fetchRecordByIdentifier query



352
353
354
355
356
357
358
359
360
# File 'lib/carddb/query_builder.rb', line 352

def fetch_record_by_identifier(include_pricing: false)
  <<~GRAPHQL
    query FetchRecordByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifier: String!) {
      fetchRecordByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifier: $identifier) {
        #{record_fields(include_pricing: include_pricing)}
      }
    }
  GRAPHQL
end

.fetch_records(include_pricing: false) ⇒ Object

Builds a fetchRecords query



385
386
387
388
389
390
391
392
393
# File 'lib/carddb/query_builder.rb', line 385

def fetch_records(include_pricing: false)
  <<~GRAPHQL
    query FetchRecords($ids: [UUID!]!) {
      fetchRecords(ids: $ids) {
        #{record_fields(include_pricing: include_pricing)}
      }
    }
  GRAPHQL
end

.fetch_records_by_identifier(include_pricing: false) ⇒ Object

Builds a fetchRecordsByIdentifier query



363
364
365
366
367
368
369
370
371
# File 'lib/carddb/query_builder.rb', line 363

def fetch_records_by_identifier(include_pricing: false)
  <<~GRAPHQL
    query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
      fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
        #{record_fields(include_pricing: include_pricing)}
      }
    }
  GRAPHQL
end

.fileObject



681
682
683
684
685
686
687
688
689
# File 'lib/carddb/query_builder.rb', line 681

def file
  <<~GRAPHQL
    query File($id: UUID!) {
      file(id: $id) {
        #{file_fields}
      }
    }
  GRAPHQL
end

.file_deleteObject



711
712
713
714
715
716
717
# File 'lib/carddb/query_builder.rb', line 711

def file_delete
  <<~GRAPHQL
    mutation FileDelete($id: UUID!) {
      fileDelete(id: $id)
    }
  GRAPHQL
end

.file_upload_confirmObject



701
702
703
704
705
706
707
708
709
# File 'lib/carddb/query_builder.rb', line 701

def file_upload_confirm
  <<~GRAPHQL
    mutation FileUploadConfirm($id: UUID!) {
      fileUploadConfirm(id: $id) {
        #{file_fields}
      }
    }
  GRAPHQL
end

.file_upload_requestObject



691
692
693
694
695
696
697
698
699
# File 'lib/carddb/query_builder.rb', line 691

def file_upload_request
  <<~GRAPHQL
    mutation FileUploadRequest($input: FileUploadInput!) {
      fileUploadRequest(input: $input) {
        #{presigned_upload_fields}
      }
    }
  GRAPHQL
end

.game(id: nil, publisher_id: nil, publisher_slug: nil, game_key: nil, game_slug: nil) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/carddb/query_builder.rb', line 127

def game(id: nil, publisher_id: nil, publisher_slug: nil, game_key: nil, game_slug: nil)
  args = build_args(
    {
      id: id,
      publisherId: publisher_id,
      publisherSlug: publisher_slug,
      gameKey: game_key,
      gameSlug: game_slug
    }
  )

  <<~GRAPHQL
    query Game#{args[:definition]} {
      game#{args[:call]} {
        #{game_fields}
      }
    }
  GRAPHQL
end

.game_import_from_fileObject



615
616
617
618
619
620
621
622
623
# File 'lib/carddb/query_builder.rb', line 615

def game_import_from_file
  <<~GRAPHQL
    mutation GameImportFromFile($input: GameImportFromFileInput!) {
      gameImportFromFile(input: $input) {
        #{game_import_job_fields}
      }
    }
  GRAPHQL
end

.game_import_from_payloadObject



625
626
627
628
629
630
631
632
633
# File 'lib/carddb/query_builder.rb', line 625

def game_import_from_payload
  <<~GRAPHQL
    mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
      gameImportFromPayload(input: $input) {
        #{game_import_job_fields}
      }
    }
  GRAPHQL
end

.game_import_from_urlObject



635
636
637
638
639
640
641
642
643
# File 'lib/carddb/query_builder.rb', line 635

def game_import_from_url
  <<~GRAPHQL
    mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
      gameImportFromUrl(input: $input) {
        #{game_import_job_fields}
      }
    }
  GRAPHQL
end

.game_import_jobObject



645
646
647
648
649
650
651
652
653
# File 'lib/carddb/query_builder.rb', line 645

def game_import_job
  <<~GRAPHQL
    query GameImportJob($id: UUID!) {
      gameImportJob(id: $id) {
        #{game_import_job_fields}
      }
    }
  GRAPHQL
end

.game_import_job_cancelObject



671
672
673
674
675
676
677
678
679
# File 'lib/carddb/query_builder.rb', line 671

def game_import_job_cancel
  <<~GRAPHQL
    mutation GameImportJobCancel($id: UUID!) {
      gameImportJobCancel(id: $id) {
        #{game_import_job_fields}
      }
    }
  GRAPHQL
end

.game_import_jobs(game_id:, status: nil, first: nil, after: nil) ⇒ Object



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/carddb/query_builder.rb', line 655

def game_import_jobs(game_id:, status: nil, first: nil, after: nil)
  args = build_args(
    { gameId: game_id, status: status, first: first, after: after },
    required: [:gameId],
    type_overrides: { status: 'ImportJobStatus' }
  )

  <<~GRAPHQL
    query GameImportJobs#{args[:definition]} {
      gameImportJobs#{args[:call]} {
        #{game_import_job_connection_fields}
      }
    }
  GRAPHQL
end

.game_import_previewObject



605
606
607
608
609
610
611
612
613
# File 'lib/carddb/query_builder.rb', line 605

def game_import_preview
  <<~GRAPHQL
    query GameImportPreview($input: GameImportPreviewInput!) {
      gameImportPreview(input: $input) {
        #{game_import_preview_fields}
      }
    }
  GRAPHQL
end

.game_scan_regionsObject



863
864
865
866
867
868
869
870
871
# File 'lib/carddb/query_builder.rb', line 863

def game_scan_regions
  <<~GRAPHQL
    query GameScanRegions($publisherSlug: String!, $gameKey: String!, $includeInactive: Boolean) {
      gameScanRegions(publisherSlug: $publisherSlug, gameKey: $gameKey, includeInactive: $includeInactive) {
        #{game_scan_region_fields}
      }
    }
  GRAPHQL
end

.grant_deck_api_application_accessObject



1687
1688
1689
1690
1691
1692
1693
1694
1695
# File 'lib/carddb/query_builder.rb', line 1687

def grant_deck_api_application_access
  <<~GRAPHQL
    mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
      deckApiApplicationAccessGrant(input: $input) {
        #{deck_api_application_access_fields}
      }
    }
  GRAPHQL
end

.import_deckObject



1473
1474
1475
1476
1477
1478
1479
1480
1481
# File 'lib/carddb/query_builder.rb', line 1473

def import_deck
  <<~GRAPHQL
    mutation DeckImport($input: DeckImportInput!) {
      deckImport(input: $input) {
        #{deck_import_payload_fields}
      }
    }
  GRAPHQL
end

.import_jobObject



552
553
554
555
556
557
558
559
560
# File 'lib/carddb/query_builder.rb', line 552

def import_job
  <<~GRAPHQL
    query ImportJob($id: UUID!) {
      importJob(id: $id) {
        #{import_job_fields}
      }
    }
  GRAPHQL
end

.import_job_cancelObject



578
579
580
581
582
583
584
585
586
# File 'lib/carddb/query_builder.rb', line 578

def import_job_cancel
  <<~GRAPHQL
    mutation ImportJobCancel($id: UUID!) {
      importJobCancel(id: $id) {
        #{import_job_fields}
      }
    }
  GRAPHQL
end

.import_job_logs(level: nil, dataset_key: nil, first: nil, after: nil) ⇒ Object



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/carddb/query_builder.rb', line 588

def import_job_logs(level: nil, dataset_key: nil, first: nil, after: nil)
  log_args = build_args(
    { level: level, datasetKey: dataset_key, first: first, after: after },
    type_overrides: { level: 'ImportLogLevel' }
  )

  <<~GRAPHQL
    query ImportJobLogs($importJobId: UUID!#{log_args[:definition].sub('(', ', ').sub(')', '')}) {
      importJob(id: $importJobId) {
        logs#{log_args[:call]} {
          #{import_job_log_connection_fields}
        }
      }
    }
  GRAPHQL
end

.import_jobs(publisher_id:, dataset_id: nil, status: nil, first: nil, after: nil) ⇒ Object



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/carddb/query_builder.rb', line 562

def import_jobs(publisher_id:, dataset_id: nil, status: nil, first: nil, after: nil)
  args = build_args(
    { publisherId: publisher_id, datasetId: dataset_id, status: status, first: first, after: after },
    required: [:publisherId],
    type_overrides: { status: 'ImportJobStatus' }
  )

  <<~GRAPHQL
    query ImportJobs#{args[:definition]} {
      importJobs#{args[:call]} {
        #{import_job_connection_fields}
      }
    }
  GRAPHQL
end

.import_ruleset_version_draft_from_dataset_recordObject



1296
1297
1298
1299
1300
1301
1302
1303
1304
# File 'lib/carddb/query_builder.rb', line 1296

def import_ruleset_version_draft_from_dataset_record
  <<~GRAPHQL
    mutation RulesetVersionDraftImportFromDatasetRecord($rulesetId: UUID!, $input: RulesetVersionDraftImportFromDatasetRecordInput!) {
      rulesetVersionDraftImportFromDatasetRecord(rulesetId: $rulesetId, input: $input) {
        #{ruleset_version_fields}
      }
    }
  GRAPHQL
end

.list_dataset_records(dataset_id:, filter: nil, order_by: nil, first: nil, after: nil, last: nil, before: nil, validate_schema: nil) ⇒ Object



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/carddb/query_builder.rb', line 395

def list_dataset_records(
  dataset_id:,
  filter: nil,
  order_by: nil,
  first: nil,
  after: nil,
  last: nil,
  before: nil,
  validate_schema: nil
)
  args = build_args(
    {
      datasetId: dataset_id,
      filter: filter,
      orderBy: order_by,
      first: first,
      after: after,
      last: last,
      before: before,
      validateSchema: validate_schema
    },
    required: [:datasetId],
    type_overrides: { orderBy: 'DatasetRecordOrderByInput' }
  )

  <<~GRAPHQL
    query DatasetRecords#{args[:definition]} {
      datasetRecords#{args[:call]} {
        #{record_connection_fields}
      }
    }
  GRAPHQL
end

.list_datasets(publisher_id:, game_id: nil, purpose: nil, first: nil, after: nil, include_archived: nil) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/carddb/query_builder.rb', line 258

def list_datasets(
  publisher_id:,
  game_id: nil,
  purpose: nil,
  first: nil,
  after: nil,
  include_archived: nil
)
  args = build_args(
    {
      publisherId: publisher_id,
      gameId: game_id,
      purpose: purpose,
      first: first,
      after: after,
      includeArchived: include_archived
    },
    required: [:publisherId]
  )

  <<~GRAPHQL
    query Datasets#{args[:definition]} {
      datasets#{args[:call]} {
        #{dataset_connection_fields(include_schema: true)}
      }
    }
  GRAPHQL
end

.list_games(publisher_id:, first: nil, after: nil, include_archived: nil) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/carddb/query_builder.rb', line 112

def list_games(publisher_id:, first: nil, after: nil, include_archived: nil)
  args = build_args(
    { publisherId: publisher_id, first: first, after: after, includeArchived: include_archived },
    required: [:publisherId]
  )

  <<~GRAPHQL
    query Games#{args[:definition]} {
      games#{args[:call]} {
        #{game_connection_fields}
      }
    }
  GRAPHQL
end

.list_my_decks(first: nil, after: nil, include_archived: nil) ⇒ Object

Builds a myDecks query



937
938
939
940
941
942
943
944
945
946
947
# File 'lib/carddb/query_builder.rb', line 937

def list_my_decks(first: nil, after: nil, include_archived: nil)
  args = build_args({ first: first, after: after, includeArchived: include_archived })

  <<~GRAPHQL
    query MyDecks#{args[:definition]} {
      myDecks#{args[:call]} {
        #{deck_connection_fields}
      }
    }
  GRAPHQL
end

.my_deckObject

Builds a myDeck query



1016
1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/carddb/query_builder.rb', line 1016

def my_deck
  <<~GRAPHQL
    query MyDeck($id: UUID!) {
      myDeck(id: $id) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.my_deck_api_application_accessesObject



1357
1358
1359
1360
1361
1362
1363
1364
1365
# File 'lib/carddb/query_builder.rb', line 1357

def my_deck_api_application_accesses
  <<~GRAPHQL
    query MyDeckApiApplicationAccesses($applicationId: UUID) {
      myDeckApiApplicationAccesses(applicationId: $applicationId) {
        #{deck_api_application_access_fields}
      }
    }
  GRAPHQL
end

.preview_scan_templateObject



847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'lib/carddb/query_builder.rb', line 847

def preview_scan_template
  <<~GRAPHQL
    mutation PreviewScanTemplate($input: PreviewScanTemplateInput!) {
      previewScanTemplate(input: $input) {
        warnings {
          #{scan_template_warning_fields}
        }
        regions {
          #{scan_template_preview_region_fields}
        }
        message
      }
    }
  GRAPHQL
end

.public_decks(filter: nil, first: nil, after: nil) ⇒ Object



979
980
981
982
983
984
985
986
987
988
989
990
991
992
# File 'lib/carddb/query_builder.rb', line 979

def public_decks(filter: nil, first: nil, after: nil)
  args = build_args(
    { filter: filter, first: first, after: after },
    type_overrides: { filter: 'PublicDecksFilterInput' }
  )

  <<~GRAPHQL
    query PublicDecks#{args[:definition]} {
      publicDecks#{args[:call]} {
        #{deck_connection_fields}
      }
    }
  GRAPHQL
end

.public_rulesets(game_id:, first: nil, after: nil) ⇒ Object



1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
# File 'lib/carddb/query_builder.rb', line 1175

def public_rulesets(game_id:, first: nil, after: nil)
  args = build_args({ gameId: game_id, first: first, after: after }, required: [:gameId])

  <<~GRAPHQL
    query PublicRulesets#{args[:definition]} {
      publicRulesets#{args[:call]} {
        #{ruleset_connection_fields}
      }
    }
  GRAPHQL
end

.publish_deckObject

Builds a deckPublish mutation



1598
1599
1600
1601
1602
1603
1604
1605
1606
# File 'lib/carddb/query_builder.rb', line 1598

def publish_deck
  <<~GRAPHQL
    mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
      deckPublish(id: $id, input: $input) {
        #{deck_publish_payload_fields}
      }
    }
  GRAPHQL
end

.publish_ruleset_versionObject



1316
1317
1318
1319
1320
1321
1322
1323
1324
# File 'lib/carddb/query_builder.rb', line 1316

def publish_ruleset_version
  <<~GRAPHQL
    mutation RulesetVersionPublish($id: UUID!, $input: RulesetVersionPublishInput) {
      rulesetVersionPublish(id: $id, input: $input) {
        #{ruleset_version_fields}
      }
    }
  GRAPHQL
end

.remove_deck_collaboratorObject

Builds a deckCollaboratorRemove mutation



1630
1631
1632
1633
1634
1635
1636
# File 'lib/carddb/query_builder.rb', line 1630

def remove_deck_collaborator
  <<~GRAPHQL
    mutation DeckCollaboratorRemove($deckId: UUID!, $accountId: UUID!) {
      deckCollaboratorRemove(deckId: $deckId, accountId: $accountId)
    }
  GRAPHQL
end

.remove_deck_entryObject



1443
1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/carddb/query_builder.rb', line 1443

def remove_deck_entry
  <<~GRAPHQL
    mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
      deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
        #{deck_entry_mutation_payload_fields}
      }
    }
  GRAPHQL
end

.remove_invalid_deck_entriesObject



1608
1609
1610
1611
1612
1613
1614
1615
1616
# File 'lib/carddb/query_builder.rb', line 1608

def remove_invalid_deck_entries
  <<~GRAPHQL
    mutation DeckRemoveInvalidEntries($id: UUID!, $input: DeckRemoveInvalidEntriesInput!) {
      deckRemoveInvalidEntries(id: $id, input: $input) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.reorder_deck_entriesObject



1453
1454
1455
1456
1457
1458
1459
1460
1461
# File 'lib/carddb/query_builder.rb', line 1453

def reorder_deck_entries
  <<~GRAPHQL
    mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
      deckEntryReorder(deckId: $deckId, input: $input) {
        #{deck_entry_reorder_payload_fields}
      }
    }
  GRAPHQL
end

.replace_deck_entriesObject



1463
1464
1465
1466
1467
1468
1469
1470
1471
# File 'lib/carddb/query_builder.rb', line 1463

def replace_deck_entries
  <<~GRAPHQL
    mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
      deckEntriesReplace(deckId: $deckId, input: $input) {
        #{deck_entry_reorder_payload_fields}
      }
    }
  GRAPHQL
end

.resolve_scan_templateObject



790
791
792
793
794
795
796
797
798
799
800
801
802
803
# File 'lib/carddb/query_builder.rb', line 790

def resolve_scan_template
  <<~GRAPHQL
    query ResolveScanTemplate($input: ResolveScanTemplateInput!) {
      resolveScanTemplate(input: $input) {
        template {
          #{scan_template_fields}
        }
        warnings {
          #{scan_template_warning_fields}
        }
      }
    }
  GRAPHQL
end

.restore_deckObject



1577
1578
1579
1580
1581
1582
1583
1584
1585
# File 'lib/carddb/query_builder.rb', line 1577

def restore_deck
  <<~GRAPHQL
    mutation DeckRestore($id: UUID!) {
      deckRestore(id: $id) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.revoke_deck_api_application_accessObject



1697
1698
1699
1700
1701
1702
1703
# File 'lib/carddb/query_builder.rb', line 1697

def revoke_deck_api_application_access
  <<~GRAPHQL
    mutation DeckApiApplicationAccessRevoke($deckId: UUID!, $apiApplicationId: UUID!) {
      deckApiApplicationAccessRevoke(deckId: $deckId, apiApplicationId: $apiApplicationId)
    }
  GRAPHQL
end

.revoke_deck_tokenObject



1679
1680
1681
1682
1683
1684
1685
# File 'lib/carddb/query_builder.rb', line 1679

def revoke_deck_token
  <<~GRAPHQL
    mutation DeckTokenRevoke($id: UUID!) {
      deckTokenRevoke(id: $id)
    }
  GRAPHQL
end

.revoke_deck_token_issuerObject



1648
1649
1650
1651
1652
1653
1654
# File 'lib/carddb/query_builder.rb', line 1648

def revoke_deck_token_issuer
  <<~GRAPHQL
    mutation DeckTokenIssuerRevoke($id: UUID!) {
      deckTokenIssuerRevoke(id: $id)
    }
  GRAPHQL
end

.revoke_deck_token_issuer_signing_keyObject



1656
1657
1658
1659
1660
1661
1662
1663
1664
# File 'lib/carddb/query_builder.rb', line 1656

def revoke_deck_token_issuer_signing_key
  <<~GRAPHQL
    mutation DeckTokenIssuerSigningKeyRevoke($id: UUID!) {
      deckTokenIssuerSigningKeyRevoke(id: $id) {
        #{deck_token_issuer_fields}
      }
    }
  GRAPHQL
end

.rulesetObject



1187
1188
1189
1190
1191
1192
1193
1194
1195
# File 'lib/carddb/query_builder.rb', line 1187

def ruleset
  <<~GRAPHQL
    query Ruleset($id: UUID, $gameId: UUID, $key: String) {
      ruleset(id: $id, gameId: $gameId, key: $key) {
        #{ruleset_fields}
      }
    }
  GRAPHQL
end

.ruleset_validation_impact(ruleset_version_id:, first: nil) ⇒ Object



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'lib/carddb/query_builder.rb', line 1251

def ruleset_validation_impact(ruleset_version_id:, first: nil)
  args = build_args(
    { rulesetVersionId: ruleset_version_id, first: first },
    required: [:rulesetVersionId]
  )

  <<~GRAPHQL
    query RulesetValidationImpact#{args[:definition]} {
      rulesetValidationImpact#{args[:call]} {
        #{ruleset_validation_impact_fields}
      }
    }
  GRAPHQL
end

.ruleset_validation_rulesObject



1223
1224
1225
1226
1227
1228
1229
# File 'lib/carddb/query_builder.rb', line 1223

def ruleset_validation_rules
  <<~GRAPHQL
    query RulesetValidationRules($gameId: UUID!, $rulesetKey: String!, $rulesetVersionId: UUID) {
      rulesetValidationRules(gameId: $gameId, rulesetKey: $rulesetKey, rulesetVersionId: $rulesetVersionId)
    }
  GRAPHQL
end

.ruleset_versionObject



1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/carddb/query_builder.rb', line 1213

def ruleset_version
  <<~GRAPHQL
    query RulesetVersion($id: UUID!) {
      rulesetVersion(id: $id) {
        #{ruleset_version_fields}
      }
    }
  GRAPHQL
end

.ruleset_version_draft_import_previewObject



1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'lib/carddb/query_builder.rb', line 1241

def ruleset_version_draft_import_preview
  <<~GRAPHQL
    query RulesetVersionDraftImportPreview($rulesetId: UUID!, $input: RulesetVersionDraftImportFromDatasetRecordInput!) {
      rulesetVersionDraftImportPreview(rulesetId: $rulesetId, input: $input) {
        #{ruleset_version_draft_import_preview_fields}
      }
    }
  GRAPHQL
end

.ruleset_versions(ruleset_id:, status: nil, first: nil, after: nil) ⇒ Object



1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/carddb/query_builder.rb', line 1197

def ruleset_versions(ruleset_id:, status: nil, first: nil, after: nil)
  args = build_args(
    { rulesetId: ruleset_id, status: status, first: first, after: after },
    required: [:rulesetId],
    type_overrides: { status: 'RulesetVersionStatus' }
  )

  <<~GRAPHQL
    query RulesetVersions#{args[:definition]} {
      rulesetVersions#{args[:call]} {
        #{ruleset_version_connection_fields}
      }
    }
  GRAPHQL
end

.rulesets(game_id:, include_archived: nil, first: nil, after: nil) ⇒ Object



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
# File 'lib/carddb/query_builder.rb', line 1160

def rulesets(game_id:, include_archived: nil, first: nil, after: nil)
  args = build_args(
    { gameId: game_id, includeArchived: include_archived, first: first, after: after },
    required: [:gameId]
  )

  <<~GRAPHQL
    query Rulesets#{args[:definition]} {
      rulesets#{args[:call]} {
        #{ruleset_connection_fields}
      }
    }
  GRAPHQL
end

.scan_jobObject



752
753
754
755
756
757
758
759
760
# File 'lib/carddb/query_builder.rb', line 752

def scan_job
  <<~GRAPHQL
    query ScanJob($id: UUID!) {
      scanJob(id: $id) {
        #{scan_job_fields}
      }
    }
  GRAPHQL
end

.scan_metricsObject



780
781
782
783
784
785
786
787
788
# File 'lib/carddb/query_builder.rb', line 780

def scan_metrics
  <<~GRAPHQL
    query ScanMetrics($input: ScanMetricsInput!) {
      scanMetrics(input: $input) {
        #{scan_metrics_fields}
      }
    }
  GRAPHQL
end

.scan_templatesObject



805
806
807
808
809
810
811
812
813
814
815
# File 'lib/carddb/query_builder.rb', line 805

def scan_templates
  <<~GRAPHQL
    query ScanTemplates($input: ScanTemplatesInput!) {
      scanTemplates(input: $input) {
        templates {
          #{scan_template_fields}
        }
      }
    }
  GRAPHQL
end

.search_datasets(publisher_slug: nil, game_key: nil, search: nil, purpose: nil, first: nil, after: nil) ⇒ Object

Builds a searchDatasets query



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/carddb/query_builder.rb', line 168

def search_datasets(publisher_slug: nil, game_key: nil, search: nil, purpose: nil, first: nil, after: nil)
  args = build_args({
                      publisherSlug: publisher_slug,
                      gameKey: game_key,
                      search: search,
                      purpose: purpose,
                      first: first,
                      after: after
                    })

  <<~GRAPHQL
    query SearchDatasets#{args[:definition]} {
      searchDatasets#{args[:call]} {
        #{dataset_connection_fields}
      }
    }
  GRAPHQL
end

.search_games(publisher_slug: nil, search: nil, first: nil, after: nil) ⇒ Object

Builds a searchGames query



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/carddb/query_builder.rb', line 62

def search_games(publisher_slug: nil, search: nil, first: nil, after: nil)
  args = build_args({
                      publisherSlug: publisher_slug,
                      search: search,
                      first: first,
                      after: after
                    })

  <<~GRAPHQL
    query SearchGames#{args[:definition]} {
      searchGames#{args[:call]} {
        #{game_connection_fields}
      }
    }
  GRAPHQL
end

.search_publishers(search: nil, first: nil, after: nil) ⇒ Object

Builds a searchPublishers query



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/carddb/query_builder.rb', line 12

def search_publishers(search: nil, first: nil, after: nil)
  args = build_args({
                      search: search,
                      first: first,
                      after: after
                    })

  <<~GRAPHQL
    query SearchPublishers#{args[:definition]} {
      searchPublishers#{args[:call]} {
        #{publisher_connection_fields}
      }
    }
  GRAPHQL
end

.search_records(publisher_slug:, game_key:, dataset_key:, filter: nil, search: nil, order_by: nil, resolve_links: nil, first: nil, after: nil, validate_schema: nil, include_pricing: false) ⇒ Object

Builds a searchRecords query rubocop:disable Metrics/ParameterLists



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/carddb/query_builder.rb', line 309

def search_records(
  publisher_slug:,
  game_key:,
  dataset_key:,
  filter: nil,
  search: nil,
  order_by: nil,
  resolve_links: nil,
  first: nil,
  after: nil,
  validate_schema: nil,
  include_pricing: false
)
  args = build_args(
    {
      publisherSlug: publisher_slug,
      gameKey: game_key,
      datasetKey: dataset_key,
      filter: filter,
      search: search,
      orderBy: order_by,
      resolveLinks: resolve_links,
      first: first,
      after: after,
      validateSchema: validate_schema
    },
    required: %i[publisherSlug gameKey datasetKey]
  )

  <<~GRAPHQL
    query SearchRecords#{args[:definition]} {
      searchRecords#{args[:call]} {
        #{record_connection_fields(
          include_resolved_links: resolve_links&.any?,
          include_pricing: include_pricing
        )}
      }
    }
  GRAPHQL
end

.submit_scan_feedbackObject



762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
# File 'lib/carddb/query_builder.rb', line 762

def submit_scan_feedback
  <<~GRAPHQL
    mutation SubmitScanFeedback($input: SubmitScanFeedbackInput!) {
      submitScanFeedback(input: $input) {
        feedbackId
        jobId
        status
        persisted
        correct
        predictedRecordId
        selectedRecordId
        featureVersion
        message
      }
    }
  GRAPHQL
end

.transfer_deck_ownershipObject



1547
1548
1549
1550
1551
1552
1553
1554
1555
# File 'lib/carddb/query_builder.rb', line 1547

def transfer_deck_ownership
  <<~GRAPHQL
    mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
      deckTransferOwnership(id: $id, input: $input) {
        #{deck_ownership_transfer_payload_fields}
      }
    }
  GRAPHQL
end

.unarchive_deck_import_formatObject



1513
1514
1515
1516
1517
1518
1519
1520
1521
# File 'lib/carddb/query_builder.rb', line 1513

def unarchive_deck_import_format
  <<~GRAPHQL
    mutation DeckImportFormatUnarchive($id: UUID!) {
      deckImportFormatUnarchive(id: $id) {
        #{deck_import_format_definition_fields}
      }
    }
  GRAPHQL
end

.unpublish_deckObject



1587
1588
1589
1590
1591
1592
1593
1594
1595
# File 'lib/carddb/query_builder.rb', line 1587

def unpublish_deck
  <<~GRAPHQL
    mutation DeckUnpublish($id: UUID!) {
      deckUnpublish(id: $id) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.update_deckObject

Builds a deckUpdate mutation



1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'lib/carddb/query_builder.rb', line 1413

def update_deck
  <<~GRAPHQL
    mutation DeckUpdate($id: UUID!, $input: DeckUpdateInput!) {
      deckUpdate(id: $id, input: $input) {
        #{deck_fields}
      }
    }
  GRAPHQL
end

.update_deck_entryObject



1433
1434
1435
1436
1437
1438
1439
1440
1441
# File 'lib/carddb/query_builder.rb', line 1433

def update_deck_entry
  <<~GRAPHQL
    mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
      deckEntryUpdate(id: $id, input: $input) {
        #{deck_entry_mutation_payload_fields}
      }
    }
  GRAPHQL
end

.update_deck_import_formatObject



1493
1494
1495
1496
1497
1498
1499
1500
1501
# File 'lib/carddb/query_builder.rb', line 1493

def update_deck_import_format
  <<~GRAPHQL
    mutation DeckImportFormatUpdate($id: UUID!, $input: DeckImportFormatUpdateInput!) {
      deckImportFormatUpdate(id: $id, input: $input) {
        #{deck_import_format_definition_fields}
      }
    }
  GRAPHQL
end

.update_gameObject



157
158
159
160
161
162
163
164
165
# File 'lib/carddb/query_builder.rb', line 157

def update_game
  <<~GRAPHQL
    mutation GameUpdate($id: UUID!, $input: GameUpdateInput!) {
      gameUpdate(id: $id, input: $input) {
        #{game_fields}
      }
    }
  GRAPHQL
end

.update_rulesetObject



1276
1277
1278
1279
1280
1281
1282
1283
1284
# File 'lib/carddb/query_builder.rb', line 1276

def update_ruleset
  <<~GRAPHQL
    mutation RulesetUpdate($id: UUID!, $input: RulesetUpdateInput!) {
      rulesetUpdate(id: $id, input: $input) {
        #{ruleset_fields}
      }
    }
  GRAPHQL
end

.update_ruleset_version_draftObject



1306
1307
1308
1309
1310
1311
1312
1313
1314
# File 'lib/carddb/query_builder.rb', line 1306

def update_ruleset_version_draft
  <<~GRAPHQL
    mutation RulesetVersionDraftUpdate($id: UUID!, $input: RulesetVersionDraftUpdateInput!) {
      rulesetVersionDraftUpdate(id: $id, input: $input) {
        #{ruleset_version_fields}
      }
    }
  GRAPHQL
end

.update_scan_templateObject



832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/carddb/query_builder.rb', line 832

def update_scan_template
  <<~GRAPHQL
    mutation UpdateScanTemplate($id: UUID!, $input: SaveScanTemplateInput!) {
      updateScanTemplate(id: $id, input: $input) {
        template {
          #{scan_template_fields}
        }
        warnings {
          #{scan_template_warning_fields}
        }
      }
    }
  GRAPHQL
end

.upsert_dataset_recordsObject



456
457
458
459
460
461
462
463
464
# File 'lib/carddb/query_builder.rb', line 456

def upsert_dataset_records
  <<~GRAPHQL
    mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
      datasetRecordsUpsert(input: $input) {
        #{dataset_records_upsert_payload_fields}
      }
    }
  GRAPHQL
end

.upsert_deck_by_external_refObject



1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
# File 'lib/carddb/query_builder.rb', line 1523

def upsert_deck_by_external_ref
  <<~GRAPHQL
    mutation DeckUpsertByExternalRef($input: DeckUpsertByExternalRefInput!) {
      deckUpsertByExternalRef(input: $input) {
        deck {
          #{deck_fields}
        }
        created
        idempotentReplay
      }
    }
  GRAPHQL
end

.upsert_deck_collaboratorObject

Builds a deckCollaboratorUpsert mutation



1619
1620
1621
1622
1623
1624
1625
1626
1627
# File 'lib/carddb/query_builder.rb', line 1619

def upsert_deck_collaborator
  <<~GRAPHQL
    mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
      deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
        #{deck_collaborator_fields}
      }
    }
  GRAPHQL
end

.viewer_decks(filter: nil, first: nil, after: nil) ⇒ Object



949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/carddb/query_builder.rb', line 949

def viewer_decks(filter: nil, first: nil, after: nil)
  args = build_args(
    { filter: filter, first: first, after: after },
    type_overrides: { filter: 'ViewerDecksFilterInput' }
  )

  <<~GRAPHQL
    query ViewerDecks#{args[:definition]} {
      viewerDecks#{args[:call]} {
        #{deck_connection_fields}
      }
    }
  GRAPHQL
end