ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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
257
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
428
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
//! The detect house's WIRE FACES — the two composites as GraphQL objects, their two filters as
//! input objects, and the composed name that keeps two instantiations of the located form apart.
//!
//! ```text
//! type Detection            { label: String!  confidence: f32! }
//! type LocatedDetectionF32  { label: String!  confidence: f32!  bbox: BoundingBoxF32! }
//!
//! input DetectionFilter           { label: LabelFilter  confidence: ConfidenceFilter }
//! input LocatedDetectionF32Filter { label: LabelFilter  confidence: ConfidenceFilter
//!                                   bbox: BoundingBoxF32Filter }
//! ```
//!
//! **THE TWO COMPOSED NAMES ONCE DIFFERED IN ONE LETTER'S CASE, and the repair is one expression.**
//! An output name composes the component's published OUTPUT form, which for a confidence-free width
//! is the roster's own scalar — and every roster scalar is LOWERCASE, that being the constitution's
//! first law: *the roster is the framework's own vocabulary, and it is Rust-flavoured*. A filter name
//! composes the component FILTER's, and those are Pascal. So `f32` went into one and `F32Filter` into
//! the other, and `LocatedDetectionf32` was what a schema actually published — beside a
//! `LocatedDetectionF32Filter` and beneath a doc sketch that said otherwise.
//!
//! Ruled 2026-08-29: **a Rust width is not a name**, so a COMPOSED name raises its tail while the
//! roster scalar keeps its own spelling where it stands alone.
//! [`composed_tail`](crate::graphql::output::composed_tail) is that raise, and it is ONE expression
//! shared with the geometry house one door over — which had the same divergence between its code and
//! its own SDL sketch, and is repaired in the same sweep. A schema holding both families therefore
//! carries one convention rather than two, and neither house can drift from the other.
//!
//! # THE CLASSIFICATION IS FLATTENED ON BOTH SIDES
//!
//! A located detection publishes `label` and `confidence` at its own level rather than behind a
//! `detection` object, and its filter takes them at that level too. Reading a finding's word costs
//! no extra selection set, which is [`DetectedLanguage`](crate::primitives::lang::DetectedLanguage)'s
//! own shape, and the two faces here agree with the six COLUMNS a located detection occupies, where
//! the classification's two are spliced for the same reason.
//!
//! The field lists are COMPOSED rather than restated: [`located_fields`] calls [`detection_fields`]
//! and adds one entry, and the parse and the render do the same. So a facet added to
//! [`DetectionFilter`](super::DetectionFilter) appears on both faces at once and the two cannot
//! drift.
//!
//! # ONE NAME IS COMPOSED AND ONE IS NOT, and the parameter is why
//!
//! [`Detection`](super::Detection) is concrete, so it publishes `Detection` and its filter publishes
//! `DetectionFilter` — the roster's Pascal law, nothing more.
//! [`LocatedDetection<T>`](super::LocatedDetection) is generic, and GraphQL keeps ONE FLAT
//! NAMESPACE, so two instantiations of it would be a name async-graphql resolves in silence. The
//! component's own published name composes onto the holder's exactly as it does for the geometry
//! family, and the OUTPUT and INPUT halves compose from different sources for that family's reason:
//! an object's name is built from the COMPONENT's published form and a filter's from the COMPONENT
//! FILTER's.
//!
//! **A `NormCoord` finding publishes `LocatedDetectionF32`**, not `LocatedDetectionNormCoord` — the
//! coordinate has no scalar of its own and crosses as `f32`'s roster carrier, whose name the raise
//! above then puts into a name's case.
//!
//! # NO WHOLE-VALUE OPERAND, and no `#[Scalar]` anywhere in the house
//!
//! Neither composite mints an operand type, because neither filter has a whole-value slot for one to
//! land in — see [`DetectionFilter`](super::DetectionFilter), where the absence is argued. It
//! follows that the crossing map carries no [`ToGraphqlInput`](crate::ToGraphqlInput) row for either
//! composite: what a client SENDS about a finding is a filter, and what it READS back is an object.
//!
//! That is also [`DetectedLanguage`](crate::primitives::lang::DetectedLanguage)'s posture, and its
//! sharper reason holds here word for word: a whole-detection `eq` would be an exact float equality
//! against a number a client typed.
//!
//! [`Label`](super::Label) publishes no scalar either, so a label field is a `String!` and a label
//! operand is a `String` — see that type's own note, where the retirement that decided it is cited.

use std::borrow::Cow;

use async_graphql::{
  InputObjectType, InputType, InputValueError, InputValueResult, Object, OutputType, TypeName,
  Value,
  indexmap::IndexMap,
  registry::{MetaInputValue, MetaType, MetaTypeId, Registry},
};

use crate::{
  BoundingBox, BoundingBoxFilter, ConfidenceFilter, NullableFace, Score, Sent, TextFilter,
  ToGraphqlOutput, graphql::output::composed_tail, sent,
};

use super::{
  BarcodeDetection, BarcodeDetectionFilter, Detection, DetectionFilter, DocumentSegment,
  DocumentSegmentFilter, Label, LabelWire, LocatedDetection, LocatedDetectionFilter, Symbology,
  TextDetection, TextDetectionFilter,
};

#[cfg(test)]
mod tests;

/// What a bare value at either of this house's filter faces omits.
///
/// ONE sentence for both, because the omission is the same one at either arity: a finding's filter
/// is a set of FACETS with no whole-value slot for a bare value to land in, so there is no reading
/// to pick and the refusal names the fields instead. That is
/// [`NO_GEOMETRY_SHORTHAND`](crate::primitives::geometry)'s own argument one house over — there is
/// no whole-shape operator for a bare value to be.
const NO_DETECTION_SHORTHAND: &str = "a detection filter asks about FACETS: name the fields you mean — a bare value does not say \
   whether it is the label, the confidence or the box, and there is no whole-detection operator \
   for it to be";

/// A classification: what something was decided to be, and how sure the decider was.
///
/// Both fields are NON-NULL — a detection is a word and a number or it is not one. There is no `box`
/// field beside them, and the absence is the type: a finding WITH a location is a
/// `LocatedDetection`, which publishes its own object.
#[Object]
impl Detection {
  /// The word the classifier put on the subject — the model's own vocabulary, neither folded nor
  /// translated by this framework.
  #[doc(hidden)]
  #[graphql(name = "label")]
  async fn __async_graphql_label__(&self) -> &str {
    <Label as ToGraphqlOutput>::to_graphql_output(self.label())
  }

  /// How confident the classifier was, in `[0.0, 1.0]`.
  // `f32`, the width's own roster scalar, reached through the confidence's OUTPUT crossing: the
  // `Score` scalar is retired, and the interval it stated is `Score::new`'s promise, said to a
  // client in the line above rather than in a scalar's name.
  #[doc(hidden)]
  #[graphql(name = "confidence")]
  async fn __async_graphql_confidence__(&self) -> crate::F32 {
    <Score as ToGraphqlOutput>::to_graphql_output(&self.confidence())
  }
}

/// **The crossing OUT** — a BORROW, resolved by the `#[Object]` above.
impl ToGraphqlOutput for Detection {
  type Output<'a> = &'a Self;

  #[inline]
  fn to_graphql_output(marked: &Self) -> &Self {
    marked
  }
}

/// `LocatedDetection<T>` publishes `LocatedDetection` before the geometry COMPONENT's own published
/// name.
///
/// The bound is [`ToGraphqlOutput`] rather than [`OutputType`], which is this crate's crossing map
/// read where async-graphql would have read its own: a component reaches the wire through the form
/// its row names, and that form is what carries a published name. `'static` is what makes
/// `Output<'static>` nameable at all — a name is asked for with no value in hand.
impl<T> TypeName for LocatedDetection<T>
where
  T: ToGraphqlOutput + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!(
      "LocatedDetection{}",
      composed_tail(&<T::Output<'static> as OutputType>::type_name())
    ))
  }
}

/// A classification and the rectangle it was found in.
///
/// All three fields are NON-NULL, and the third is the type's whole subject: a located detection has
/// a box, which is what distinguishes it from a [`Detection`].
///
/// The classification's two fields are FLATTENED here rather than nested behind a `detection`
/// object, so reading a finding's word costs no extra selection set — the shape the sibling house
/// takes, for the same reason.
#[Object(name_type)]
impl<T> LocatedDetection<T>
where
  T: ToGraphqlOutput + Copy + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  /// The word the classifier put on the subject.
  #[doc(hidden)]
  #[graphql(name = "label")]
  async fn __async_graphql_label__(&self) -> &str {
    <Label as ToGraphqlOutput>::to_graphql_output(self.label())
  }

  /// How confident the classifier was, in `[0.0, 1.0]`.
  #[doc(hidden)]
  #[graphql(name = "confidence")]
  async fn __async_graphql_confidence__(&self) -> crate::F32 {
    <Score as ToGraphqlOutput>::to_graphql_output(&self.confidence())
  }

  /// Where it was found — an axis-aligned rectangle with the TOP-LEFT origin that family measures
  /// against.
  #[doc(hidden)]
  #[graphql(name = "bbox")]
  async fn __async_graphql_bbox__(&self) -> &BoundingBox<T> {
    self.bbox()
  }
}

/// **The crossing OUT** — a BORROW, resolved by the `#[Object]` above.
impl<T> ToGraphqlOutput for LocatedDetection<T> {
  type Output<'a>
    = &'a Self
  where
    T: 'a;

  #[inline]
  fn to_graphql_output(marked: &Self) -> &Self {
    marked
  }
}

/// The field list [`DetectionFilter`](super::DetectionFilter)'s face registers, in declaration
/// order — and the FIRST TWO of the located face's, which calls this rather than restating them.
fn detection_fields(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
  crate::__ingraph_filter_input_fields!(
    registry,
    "label" : Option<TextFilter<Label, LabelWire>>,
    "confidence" : Option<ConfidenceFilter>,
  )
}

/// The object [`DetectionFilter`](super::DetectionFilter)'s face renders — the same two names in the
/// same order.
fn detection_values(filter: &DetectionFilter) -> IndexMap<async_graphql::Name, Value> {
  crate::__ingraph_filter_value_map!(filter, "label" : label, "confidence" : confidence)
}

/// The two facets a classification is asked about, read off a longhand object — the PARSE half of
/// the composition, shared by both faces so a facet added tomorrow arrives at each of them.
fn detection_facets(
  object: &IndexMap<async_graphql::Name, Value>,
) -> InputValueResult<DetectionFilter> {
  Ok(DetectionFilter {
    label: InputType::parse(object.get("label").cloned()).map_err(InputValueError::propagate)?,
    confidence: InputType::parse(object.get("confidence").cloned())
      .map_err(InputValueError::propagate)?,
  })
}

/// **The TWO-FACET face**, under this crate's own name for the type it guards.
impl InputType for DetectionFilter {
  type RawValueType = Self;

  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Borrowed("DetectionFilter")
  }

  fn create_type_info(registry: &mut Registry) -> String {
    registry.create_input_type::<Self, _>(MetaTypeId::InputObject, |registry| {
      MetaType::InputObject {
        name: String::from(<Self as InputType>::type_name()),
        description: None,
        input_fields: <Self as NullableFace>::bare_fields(registry),
        visible: None,
        inaccessible: false,
        tags: Vec::new(),
        rust_typename: Some(std::any::type_name::<Self>()),
        oneof: false,
        directive_invocations: Vec::new(),
      }
    })
  }

  /// # NO SHORTHAND — see [`NO_DETECTION_SHORTHAND`]
  fn parse(value: Option<Value>) -> InputValueResult<Self> {
    let object = match sent(value) {
      Sent::Longhand(object) => object,
      Sent::Bare(_) => return Err(InputValueError::custom(NO_DETECTION_SHORTHAND)),
      Sent::Null => return Err(InputValueError::expected_type(Value::Null)),
      Sent::Refused(refused) => return Err(InputValueError::expected_type(refused)),
    };

    detection_facets(&object)
  }

  fn to_value(&self) -> Value {
    Value::Object(<Self as NullableFace>::bare_values(self))
  }

  #[inline]
  fn as_raw_value(&self) -> Option<&Self::RawValueType> {
    Some(self)
  }
}

impl InputObjectType for DetectionFilter {}

/// The NULLABLE row — the two pieces [`Nullable`](crate::Nullable)'s blanket assembles this face's
/// twin from, so an `Option<Detection>` column publishes the filter with `isNull` appended and no
/// second field list anywhere.
impl NullableFace for DetectionFilter {
  fn bare_fields(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
    detection_fields(registry)
  }

  fn bare_values(&self) -> IndexMap<async_graphql::Name, Value> {
    detection_values(self)
  }
}

/// The field list [`LocatedDetectionFilter`](super::LocatedDetectionFilter)'s face registers — the
/// classification's two, then the box.
fn located_fields<CF>(registry: &mut Registry) -> IndexMap<String, MetaInputValue>
where
  CF: InputType,
{
  let mut fields = detection_fields(registry);

  fields.extend(crate::__ingraph_filter_input_fields!(
    registry,
    "bbox" : Option<BoundingBoxFilter<CF>>,
  ));

  fields
}

/// The object [`LocatedDetectionFilter`](super::LocatedDetectionFilter)'s face renders — the same
/// three names in the same order.
fn located_values<CF>(filter: &LocatedDetectionFilter<CF>) -> IndexMap<async_graphql::Name, Value>
where
  CF: InputType,
{
  let mut values = detection_values(&filter.detection);

  values.extend(crate::__ingraph_filter_value_map!(filter, "bbox" : bbox));

  values
}

/// **The THREE-FACET face**, named `LocatedDetection` before the COMPONENT FILTER's own input name.
///
/// The name composes from `CF` and not from [`BoundingBoxFilter<CF>`], which is what keeps it short
/// and what keeps it HONEST: the box is this type's own shape rather than a parameter, so a name
/// carrying the nested filter's would repeat `BoundingBox` in a position where nothing varies. That
/// is [`QuadFilter`](crate::QuadFilter)'s own sentence at its own arity.
impl<CF> InputType for LocatedDetectionFilter<CF>
where
  CF: InputType,
{
  type RawValueType = Self;

  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!(
      "LocatedDetection{}",
      <CF as InputType>::type_name()
    ))
  }

  fn create_type_info(registry: &mut Registry) -> String {
    registry.create_input_type::<Self, _>(MetaTypeId::InputObject, |registry| {
      MetaType::InputObject {
        name: String::from(<Self as InputType>::type_name()),
        description: None,
        input_fields: <Self as NullableFace>::bare_fields(registry),
        visible: None,
        inaccessible: false,
        tags: Vec::new(),
        rust_typename: Some(std::any::type_name::<Self>()),
        oneof: false,
        directive_invocations: Vec::new(),
      }
    })
  }

  /// # NO SHORTHAND — see [`NO_DETECTION_SHORTHAND`]
  fn parse(value: Option<Value>) -> InputValueResult<Self> {
    let object = match sent(value) {
      Sent::Longhand(object) => object,
      Sent::Bare(_) => return Err(InputValueError::custom(NO_DETECTION_SHORTHAND)),
      Sent::Null => return Err(InputValueError::expected_type(Value::Null)),
      Sent::Refused(refused) => return Err(InputValueError::expected_type(refused)),
    };

    Ok(Self {
      detection: detection_facets(&object).map_err(InputValueError::propagate)?,
      bbox: InputType::parse(object.get("bbox").cloned()).map_err(InputValueError::propagate)?,
    })
  }

  fn to_value(&self) -> Value {
    Value::Object(<Self as NullableFace>::bare_values(self))
  }

  #[inline]
  fn as_raw_value(&self) -> Option<&Self::RawValueType> {
    Some(self)
  }
}

impl<CF: InputType> InputObjectType for LocatedDetectionFilter<CF> {}

/// The NULLABLE row, for [`DetectionFilter`](super::DetectionFilter)'s reason one facet up.
impl<CF: InputType> NullableFace for LocatedDetectionFilter<CF> {
  fn bare_fields(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
    located_fields::<CF>(registry)
  }

  fn bare_values(&self) -> IndexMap<async_graphql::Name, Value> {
    located_values(self)
  }
}

/// **A BARCODE STANDARD, read WIDE and written back CANONICAL**: `"QR"`, `"qr"` and `"Qr"` are one
/// operand and come back as `qr`.
///
/// A SCALAR rather than a schema `enum`, and the escape is why: the roster is Apple's Vision list
/// read out of a documentation page, so a decoder this crate has not met reads a standard this crate
/// has not named — and a schema `enum` would promise the members are the whole set. What that buys a
/// client is a `notIn` over the roster, which is *a code read under something nobody here names* and
/// a question no closed enum can express.
///
/// What is refused is a JSON value that is not a STRING. There is no spelling this door turns away.
#[async_graphql::Scalar(name = "Symbology")]
impl async_graphql::ScalarType for Symbology {
  #[inline]
  fn parse(value: Value) -> InputValueResult<Self> {
    match &value {
      Value::String(text) => Ok(Self::new(text)),
      _ => Err(InputValueError::expected_type(value.clone())),
    }
  }

  /// The SOLE notion of validity, and it is the JSON KIND alone — async-graphql's default answers
  /// `true` for every value, so a scalar narrowing in `parse` alone would ship a validator admitting
  /// what its own parser rejects.
  #[inline]
  fn is_valid(value: &Value) -> bool {
    matches!(value, Value::String(_))
  }

  /// STRICT OUT: the canonical slug, whichever spelling came in.
  #[inline]
  fn to_value(&self) -> Value {
    Value::String(String::from(self.as_str()))
  }
}

/// `TextDetection<T>` publishes `TextDetection` before the geometry COMPONENT's own published name,
/// on [`LocatedDetection<T>`](super::LocatedDetection)'s terms.
impl<T> TypeName for TextDetection<T>
where
  T: ToGraphqlOutput + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!(
      "TextDetection{}",
      composed_tail(&<T::Output<'static> as OutputType>::type_name())
    ))
  }
}

/// Words that were read out of a region of the frame.
///
/// All three fields are NON-NULL. `text` may be the EMPTY string and that is a real observation
/// rather than a hole — a recogniser that found a region and no characters in it — which is the one
/// place this object parts company with a classification's `label`.
#[Object(name_type)]
impl<T> TextDetection<T>
where
  T: ToGraphqlOutput + Copy + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  /// The words that were read, exactly as the recogniser gave them — neither folded nor trimmed by
  /// this framework.
  #[doc(hidden)]
  #[graphql(name = "text")]
  async fn __async_graphql_text__(&self) -> &str {
    self.text()
  }

  /// How confident the recogniser was, in `[0.0, 1.0]`.
  #[doc(hidden)]
  #[graphql(name = "confidence")]
  async fn __async_graphql_confidence__(&self) -> crate::F32 {
    <Score as ToGraphqlOutput>::to_graphql_output(&self.confidence())
  }

  /// The region the words were read from.
  #[doc(hidden)]
  #[graphql(name = "bbox")]
  async fn __async_graphql_bbox__(&self) -> &BoundingBox<T> {
    self.bbox()
  }
}

/// **The crossing OUT** — a BORROW, resolved by the `#[Object]` above.
impl<T> ToGraphqlOutput for TextDetection<T> {
  type Output<'a>
    = &'a Self
  where
    T: 'a;

  #[inline]
  fn to_graphql_output(marked: &Self) -> &Self {
    marked
  }
}

/// `BarcodeDetection<T>` publishes `BarcodeDetection` before the geometry COMPONENT's own name.
impl<T> TypeName for BarcodeDetection<T>
where
  T: ToGraphqlOutput + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!(
      "BarcodeDetection{}",
      composed_tail(&<T::Output<'static> as OutputType>::type_name())
    ))
  }
}

/// A machine-readable code that was decoded, the standard it was read under, and where it was.
///
/// All four fields are NON-NULL. `symbology` publishes the `Symbology` SCALAR rather than a schema
/// enum, for that type's own reason: the vocabulary is open, and a client reading a standard nobody
/// here names gets the word rather than a hole.
#[Object(name_type)]
impl<T> BarcodeDetection<T>
where
  T: ToGraphqlOutput + Copy + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  /// What the code carried — its own content, read back.
  #[doc(hidden)]
  #[graphql(name = "payload")]
  async fn __async_graphql_payload__(&self) -> &str {
    self.payload()
  }

  /// Which barcode standard it was read under, as the canonical slug.
  #[doc(hidden)]
  #[graphql(name = "symbology")]
  async fn __async_graphql_symbology__(&self) -> Symbology {
    self.symbology().clone()
  }

  /// How confident the decoder was, in `[0.0, 1.0]`.
  #[doc(hidden)]
  #[graphql(name = "confidence")]
  async fn __async_graphql_confidence__(&self) -> crate::F32 {
    <Score as ToGraphqlOutput>::to_graphql_output(&self.confidence())
  }

  /// The region the code was read from.
  #[doc(hidden)]
  #[graphql(name = "bbox")]
  async fn __async_graphql_bbox__(&self) -> &BoundingBox<T> {
    self.bbox()
  }
}

/// **The crossing OUT** — a BORROW, resolved by the `#[Object]` above.
impl<T> ToGraphqlOutput for BarcodeDetection<T> {
  type Output<'a>
    = &'a Self
  where
    T: 'a;

  #[inline]
  fn to_graphql_output(marked: &Self) -> &Self {
    marked
  }
}

/// `DocumentSegment<T>` publishes `DocumentSegment` before the geometry COMPONENT's own name.
impl<T> TypeName for DocumentSegment<T>
where
  T: ToGraphqlOutput + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!(
      "DocumentSegment{}",
      composed_tail(&<T::Output<'static> as OutputType>::type_name())
    ))
  }
}

/// A four-cornered region a detector found, and how sure it was.
///
/// Both fields are NON-NULL. There is no `bounds` field beside them, and the absence is the geometry
/// house's own argument said to a client: the axis-aligned box around a quad is `min`/`max` over
/// four corners a client already has, and a published one would be a fact a schema could come to
/// disagree with the corners about.
#[Object(name_type)]
impl<T> DocumentSegment<T>
where
  T: ToGraphqlOutput + Copy + Send + Sync + 'static,
  for<'a> T::Output<'a>: OutputType,
{
  /// The four corners, in PERIMETER WINDING ORDER — top-left, top-right, bottom-right, bottom-left.
  #[doc(hidden)]
  #[graphql(name = "quad")]
  async fn __async_graphql_quad__(&self) -> &crate::Quad<T> {
    self.quad()
  }

  /// How sure the detector was, in `[0.0, 1.0]`.
  #[doc(hidden)]
  #[graphql(name = "confidence")]
  async fn __async_graphql_confidence__(&self) -> crate::F32 {
    <Score as ToGraphqlOutput>::to_graphql_output(&self.confidence())
  }
}

/// **The crossing OUT** — a BORROW, resolved by the `#[Object]` above.
impl<T> ToGraphqlOutput for DocumentSegment<T> {
  type Output<'a>
    = &'a Self
  where
    T: 'a;

  #[inline]
  fn to_graphql_output(marked: &Self) -> &Self {
    marked
  }
}

/// The field list [`TextDetectionFilter`](super::TextDetectionFilter)'s face registers.
fn text_fields<CF: InputType>(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
  crate::__ingraph_filter_input_fields!(
    registry,
    "text" : Option<TextFilter<smol_bytes::Utf8Bytes>>,
    "confidence" : Option<ConfidenceFilter>,
    "bbox" : Option<BoundingBoxFilter<CF>>,
  )
}

/// The object [`TextDetectionFilter`](super::TextDetectionFilter)'s face renders.
fn text_values<CF: InputType>(
  filter: &TextDetectionFilter<CF>,
) -> IndexMap<async_graphql::Name, Value> {
  crate::__ingraph_filter_value_map!(
    filter,
    "text" : text,
    "confidence" : confidence,
    "bbox" : bbox
  )
}

/// **The THREE-FACET face**, named `TextDetection` before the COMPONENT FILTER's own input name.
impl<CF: InputType> InputType for TextDetectionFilter<CF> {
  type RawValueType = Self;

  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!("TextDetection{}", <CF as InputType>::type_name()))
  }

  fn create_type_info(registry: &mut Registry) -> String {
    registry.create_input_type::<Self, _>(MetaTypeId::InputObject, |registry| {
      MetaType::InputObject {
        name: String::from(<Self as InputType>::type_name()),
        description: None,
        input_fields: <Self as NullableFace>::bare_fields(registry),
        visible: None,
        inaccessible: false,
        tags: Vec::new(),
        rust_typename: Some(std::any::type_name::<Self>()),
        oneof: false,
        directive_invocations: Vec::new(),
      }
    })
  }

  /// # NO SHORTHAND — see [`NO_DETECTION_SHORTHAND`]
  fn parse(value: Option<Value>) -> InputValueResult<Self> {
    let object = match sent(value) {
      Sent::Longhand(object) => object,
      Sent::Bare(_) => return Err(InputValueError::custom(NO_DETECTION_SHORTHAND)),
      Sent::Null => return Err(InputValueError::expected_type(Value::Null)),
      Sent::Refused(refused) => return Err(InputValueError::expected_type(refused)),
    };

    Ok(Self {
      text: InputType::parse(object.get("text").cloned()).map_err(InputValueError::propagate)?,
      confidence: InputType::parse(object.get("confidence").cloned())
        .map_err(InputValueError::propagate)?,
      bbox: InputType::parse(object.get("bbox").cloned()).map_err(InputValueError::propagate)?,
    })
  }

  fn to_value(&self) -> Value {
    Value::Object(<Self as NullableFace>::bare_values(self))
  }

  #[inline]
  fn as_raw_value(&self) -> Option<&Self::RawValueType> {
    Some(self)
  }
}

impl<CF: InputType> InputObjectType for TextDetectionFilter<CF> {}

/// The NULLABLE row — the two pieces [`Nullable`](crate::Nullable)'s blanket assembles this face's
/// twin from.
impl<CF: InputType> NullableFace for TextDetectionFilter<CF> {
  fn bare_fields(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
    text_fields::<CF>(registry)
  }

  fn bare_values(&self) -> IndexMap<async_graphql::Name, Value> {
    text_values(self)
  }
}

/// The field list [`BarcodeDetectionFilter`](super::BarcodeDetectionFilter)'s face registers.
fn barcode_fields<CF: InputType>(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
  crate::__ingraph_filter_input_fields!(
    registry,
    "payload" : Option<TextFilter<smol_bytes::Utf8Bytes>>,
    "symbology" : Option<crate::EnumFilter<Symbology>>,
    "confidence" : Option<ConfidenceFilter>,
    "bbox" : Option<BoundingBoxFilter<CF>>,
  )
}

/// The object [`BarcodeDetectionFilter`](super::BarcodeDetectionFilter)'s face renders.
fn barcode_values<CF: InputType>(
  filter: &BarcodeDetectionFilter<CF>,
) -> IndexMap<async_graphql::Name, Value> {
  crate::__ingraph_filter_value_map!(
    filter,
    "payload" : payload,
    "symbology" : symbology,
    "confidence" : confidence,
    "bbox" : bbox
  )
}

/// **The FOUR-FACET face**, named `BarcodeDetection` before the COMPONENT FILTER's own input name.
impl<CF: InputType> InputType for BarcodeDetectionFilter<CF> {
  type RawValueType = Self;

  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!(
      "BarcodeDetection{}",
      <CF as InputType>::type_name()
    ))
  }

  fn create_type_info(registry: &mut Registry) -> String {
    registry.create_input_type::<Self, _>(MetaTypeId::InputObject, |registry| {
      MetaType::InputObject {
        name: String::from(<Self as InputType>::type_name()),
        description: None,
        input_fields: <Self as NullableFace>::bare_fields(registry),
        visible: None,
        inaccessible: false,
        tags: Vec::new(),
        rust_typename: Some(std::any::type_name::<Self>()),
        oneof: false,
        directive_invocations: Vec::new(),
      }
    })
  }

  /// # NO SHORTHAND — see [`NO_DETECTION_SHORTHAND`]
  fn parse(value: Option<Value>) -> InputValueResult<Self> {
    let object = match sent(value) {
      Sent::Longhand(object) => object,
      Sent::Bare(_) => return Err(InputValueError::custom(NO_DETECTION_SHORTHAND)),
      Sent::Null => return Err(InputValueError::expected_type(Value::Null)),
      Sent::Refused(refused) => return Err(InputValueError::expected_type(refused)),
    };

    Ok(Self {
      payload: InputType::parse(object.get("payload").cloned())
        .map_err(InputValueError::propagate)?,
      symbology: InputType::parse(object.get("symbology").cloned())
        .map_err(InputValueError::propagate)?,
      confidence: InputType::parse(object.get("confidence").cloned())
        .map_err(InputValueError::propagate)?,
      bbox: InputType::parse(object.get("bbox").cloned()).map_err(InputValueError::propagate)?,
    })
  }

  fn to_value(&self) -> Value {
    Value::Object(<Self as NullableFace>::bare_values(self))
  }

  #[inline]
  fn as_raw_value(&self) -> Option<&Self::RawValueType> {
    Some(self)
  }
}

impl<CF: InputType> InputObjectType for BarcodeDetectionFilter<CF> {}

impl<CF: InputType> NullableFace for BarcodeDetectionFilter<CF> {
  fn bare_fields(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
    barcode_fields::<CF>(registry)
  }

  fn bare_values(&self) -> IndexMap<async_graphql::Name, Value> {
    barcode_values(self)
  }
}

/// The field list [`DocumentSegmentFilter`](super::DocumentSegmentFilter)'s face registers.
fn segment_fields<CF: InputType>(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
  crate::__ingraph_filter_input_fields!(
    registry,
    "quad" : Option<crate::QuadFilter<CF>>,
    "confidence" : Option<ConfidenceFilter>,
  )
}

/// The object [`DocumentSegmentFilter`](super::DocumentSegmentFilter)'s face renders.
fn segment_values<CF: InputType>(
  filter: &DocumentSegmentFilter<CF>,
) -> IndexMap<async_graphql::Name, Value> {
  crate::__ingraph_filter_value_map!(filter, "quad" : quad, "confidence" : confidence)
}

/// **The TWO-FACET face**, named `DocumentSegment` before the COMPONENT FILTER's own input name.
impl<CF: InputType> InputType for DocumentSegmentFilter<CF> {
  type RawValueType = Self;

  #[inline]
  fn type_name() -> Cow<'static, str> {
    Cow::Owned(format!("DocumentSegment{}", <CF as InputType>::type_name()))
  }

  fn create_type_info(registry: &mut Registry) -> String {
    registry.create_input_type::<Self, _>(MetaTypeId::InputObject, |registry| {
      MetaType::InputObject {
        name: String::from(<Self as InputType>::type_name()),
        description: None,
        input_fields: <Self as NullableFace>::bare_fields(registry),
        visible: None,
        inaccessible: false,
        tags: Vec::new(),
        rust_typename: Some(std::any::type_name::<Self>()),
        oneof: false,
        directive_invocations: Vec::new(),
      }
    })
  }

  /// # NO SHORTHAND — see [`NO_DETECTION_SHORTHAND`]
  fn parse(value: Option<Value>) -> InputValueResult<Self> {
    let object = match sent(value) {
      Sent::Longhand(object) => object,
      Sent::Bare(_) => return Err(InputValueError::custom(NO_DETECTION_SHORTHAND)),
      Sent::Null => return Err(InputValueError::expected_type(Value::Null)),
      Sent::Refused(refused) => return Err(InputValueError::expected_type(refused)),
    };

    Ok(Self {
      quad: InputType::parse(object.get("quad").cloned()).map_err(InputValueError::propagate)?,
      confidence: InputType::parse(object.get("confidence").cloned())
        .map_err(InputValueError::propagate)?,
    })
  }

  fn to_value(&self) -> Value {
    Value::Object(<Self as NullableFace>::bare_values(self))
  }

  #[inline]
  fn as_raw_value(&self) -> Option<&Self::RawValueType> {
    Some(self)
  }
}

impl<CF: InputType> InputObjectType for DocumentSegmentFilter<CF> {}

impl<CF: InputType> NullableFace for DocumentSegmentFilter<CF> {
  fn bare_fields(registry: &mut Registry) -> IndexMap<String, MetaInputValue> {
    segment_fields::<CF>(registry)
  }

  fn bare_values(&self) -> IndexMap<async_graphql::Name, Value> {
    segment_values(self)
  }
}