Expand description
The ELEMENT MODE’s model — a declared element’s own filter, and the citizenship it needs.
The ELEMENT MODE’s model: what #[derive(ingraph::Filter)] emits when the declaration wears
#[ingraph(operator(<family>))] — a filter type the DECLARING crate owns, plus the citizenship
its element needs to be an operand at all.
§The wall this walks around
A declaring crate’s own element could not be filtered under most families, and the reason was the
orphan rule read from one side. TextFilter<Tag>, ScalarFilter<Db> and BytesFilter<Sum> are
FOREIGN types there, so impl async_graphql::InputType for any of them is E0117 — RFC 2451
does not admit ForeignTrait for ForeignType<Local>, the trait taking no parameter for a local
type to sit in — and ingraph could not write the row either: every one of those faces was one
REGISTRATION PER OPERAND, and the set of a declarer’s operands is open.
The wall is not climbed. This door MINTS <T>Filter in the declaring crate, so every impl below
names a local self type and coherence is never in the conversation.
§The framework has since opened a SECOND road, and this one is not the lesser of the two
ingraph’s three carrier readings — TextWire, ScalarWire, BytesWire — moved every one of
those registrations onto a marker, so a declaring crate can now reach the framework’s OWN filter
by writing a reading instead of taking a mint. The two answer different questions and a
declaration picks by what it wants:
- a MINT gives the element a filter type of its own, with a name and an inherent face the declaring crate owns, and it is the road for an element that also wants the scalar, the output crossing and the marker rows this door writes;
- a READING gives the element the framework’s own filter under a name the reading chooses, with no new type at all — one impl where this door emits a dozen.
Neither is going away, and nothing here changed: this door emits what it always did.
§What the minted filter HOLDS, and why it is a newtype
The framework’s own filter for the family, at the element — TagFilter(TextFilter<Tag>). The
operation set, the emptiness answer and the lowering map are therefore the framework’s, stated
once, and this door adds a face rather than a second implementation of the family. A minted type
whose slots were its own would be the text family’s twenty operators written a second time, in a
crate that cannot see when the first ones change.
§The NULLABLE wall came down, and the ENUM family’s ALIAS came down with it
A newtype’s remaining cost used to be the same orphan rule one type over: Nullable is the
framework’s, so impl InputType for Nullable<TagFilter> is E0117 here, and an Option<Tag>
column had no wire face at all. The framework’s own answer is ingraph::NullableFace — a
delegation trait it writes ONE blanket Nullable<F> row over — and this door writes that trait
on the minted filter, whose self type is local. So Option<Tag> is spellable now, for the
reason Option<Codec> always was, and no family is on the wall.
The ENUM family used to route AROUND that wall instead of standing off it: its door was a TYPE
ALIAS, pub type CodecFilter = EnumFilter<Codec>, so Nullable<CodecFilter> was
Nullable<EnumFilter<Codec>> and resolved into a row ingraph had already written. With the
wall down the detour bought nothing and went on charging three accounts, all of them now closed:
- NOMINAL DISTINCTNESS. An alias is not a type, so an impl written on the door’s name was an
impl on
EnumFilter<T>—E0119against the framework’s own generic rows, measured iningraph’stests/element_mint_parity.rs. A row of exactly that shape is how a minted element reaches a dialect (tests/nullable_face.rswrites one for the scalar family), so the enum family was the one family whose elements could not have a crossing of their own. - THE RENAME WORD.
filter(rename = "…")moved the RUST name and left the wire name whereEnumFilter<T>’s own derivation put it, where the other three families moved both. - TWO SHAPES TO MAINTAIN. Every emission below had to answer does this family mint, and every reader of this file had to carry the answer.
The SDL did not move when the alias retired, and that is arithmetic rather than luck:
EnumFilter<T> named itself <T's schema name>Filter and a mint names itself
RustSafeName::external, which for an element that renames nothing is the same string. What
the mint adds is that a RENAME now moves it, which is the second account above.
So there is ONE shape at four doors, and ElementModel::emit writes it once.
§WHAT THE MINT HANDS ON, and the two rows that are one decision
A minted filter is a value somebody else lowers, so the door owes a way OUT of it as well as a
way in. into_inner is that way — the held filter taken by value — and it is what every crossing
actually wants: an entry point that lowers a filter consumes it, so a hand-written row reached
through get had to clone a value its caller already owned.
The DECLARED-CONVERTER leg needs one more thing, and it is the same fact stated as a trait:
every crossing entry takes its filter as TryMapFilter<D, V> — the wrapper’s
(SqlNullable::<C>::try_from_filter_with) and, since the byte kinds split, all ten flat ones too
— so an element column with comparison(<db>(into = "…")) written on it reaches a bound the mint
has to satisfy, Option or not. ElementModel::operand_map emits that row, delegating through
into_inner — which is why the two land together rather than one at a time.
§The element’s OWN citizenship comes with it
A filter’s operand crosses the wire, so the element needs a wire face before its filter can have
one — and that face is the half only the declaring crate can write. It is emitted here for the
same reason #[derive(ingraph::Enum)] emits a vocabulary’s: it is mechanical from the
declaration, and a door that minted the filter and left the operand to a hand-written #[Scalar]
would be a door that does not close.
The scalar is async-graphql’s own attribute over an impl ScalarType, which is what a declaring
crate wrote by hand before this door existed — the same tokens, from the same declaration, so the
retirement of a hand impl is a deletion rather than a translation. It also settles the OUTPUT
leg’s boxed-trait question by not asking it: the attribute runs inside async-graphql and writes
whichever resolve shape that build compiled, where an async fn written out here would compile
under one of the two.
§The wire form is the INNER type’s, under the ELEMENT’s name
Tag(String) crosses as a string, Db(u32) as a number, Sum(Vec<u8>) as whatever Vec<u8>’s
own face renders — the element does not invent a grammar, it names one. The SDL name defaults to
the element’s Rust name and is moved by the declaration’s own graphql(rename = "…"), which is
#[derive(ingraph::Enum)]’s word for its reason: a wire type name is a schema commitment, and a
commitment gets a word of its OWN rather than riding on a Rust rename.
Structs§
- Element
Model - A declared ELEMENT, as the element mode reads it.
Enums§
- Element
Family - A family an ELEMENT may be read under — the word
operator(…)takes.