macro_rules! filter_input_object {
(
$filter:ty : $gql:literal {
bare $bare:ident : $bfty:ty => $bname:literal
$(, $field:ident : $fty:ty => $name:literal )* $(,)?
}
) => { ... };
}async-graphql only.Expand description
Emit the hand-written wire face for ONE concrete filter instantiation: its
async_graphql::InputType (+ InputObjectType) pair, and the NullableFace row a NULLABLE
column of that type reaches its face through. $filter is the concrete type (e.g.
ScalarFilter<i64>), $gql its GraphQL input name, and each $field: $fty => $name is a struct
field, its InputType field type, and its GraphQL name.
Three impls from one invocation, and that is the point. Nullability is a type here, so a
registered filter needs a second wire face — the one carrying isNull — and the way that face
went missing once already is a registration site that could mint one alone. This macro has no arm
that does: there is no expansion yielding the bare impls by themselves.
§The nullable half is a ROW rather than an impl, and that is what opened the surface
It used to be a second impl InputType for Nullable<$filter> written out here per registration,
and a table of concrete rows is a table only this crate can extend — the same wall
TextWire took TextFilter off. Nullable<F>’s face is now ONE blanket over
NullableFace, which every row here feeds, and a declaring crate joins by implementing that
trait on a filter it owns.
So this macro writes the two pieces a bare face keeps to itself — its field list and its rendered
slots — and the blanket assembles the twin: Nullable before $gql, the fields with isNull
appended, and a parse that hands the SAME object to $filter’s own. The bare face reads BOTH
pieces back off the row, so the field list is written once per invocation and the two faces cannot
come to publish different names in different orders.
A hand-written impl (not the InputObject derive) is required because the derive puts
T: InputType on the struct (it generates generic internal parse methods), which would break
the bound-free filter structs and every to_filter! registration whose operand has no scalar —
i128, u128 and the byte vocabularies among them.
Neither impl overrides InputType::federation_fields (the InputObject derive does, emitting the
Apollo Federation field set): there is no Apollo Federation usage in-repo, so the trait’s None
default is correct — a future federation adopter overrides it here.