use crate::{
graphql::lower::ToGraphqlFilter,
marker::{BytesFilterMarker, BytesMarker, DefaultMarker, DefaultVecMarker, ListMarker},
primitives::{Confidence, Count, Timestamp},
};
macro_rules! opt_accessor {
($field:ident: [$elem:ty] => $with:ident, $set:ident, $maybe:ident, $update:ident) => {
#[doc = concat!("The `", stringify!($field), "` operands, or `None` while the operator is absent.")]
#[doc = ""]
#[doc = "A PRESENT but empty list is not the same as an absent operator: the first asks for no"]
#[doc = "rows, the second for every row, so `Some(&[])` and `None` say different things."]
#[inline]
pub fn $field(&self) -> Option<&[$elem]> {
self.$field.as_deref()
}
#[doc = concat!("Set `", stringify!($field), "` to `Some(value)` (consuming).")]
#[must_use]
#[inline]
pub fn $with(mut self, value: impl Into<Box<[$elem]>>) -> Self {
self.$field = Some(value.into());
self
}
#[doc = concat!("Set `", stringify!($field), "` to `Some(value)` (in place).")]
#[inline]
pub fn $set(&mut self, value: impl Into<Box<[$elem]>>) -> &mut Self {
self.$field = Some(value.into());
self
}
#[doc = concat!("Assign the `", stringify!($field), "` list option (consuming).")]
#[must_use]
#[inline]
pub fn $maybe(mut self, value: Option<impl Into<Box<[$elem]>>>) -> Self {
self.$field = value.map(Into::into);
self
}
#[doc = concat!("Assign the `", stringify!($field), "` list option (in place).")]
#[inline]
pub fn $update(&mut self, value: Option<impl Into<Box<[$elem]>>>) -> &mut Self {
self.$field = value.map(Into::into);
self
}
};
($field:ident: $ty:ty => $with:ident, $set:ident, $maybe:ident, $update:ident) => {
#[doc = concat!("The `", stringify!($field), "` operand, or `None` while the operator is absent.")]
#[inline]
pub const fn $field(&self) -> Option<&$ty> {
self.$field.as_ref()
}
#[doc = concat!("Set `", stringify!($field), "` to `Some(value)` (consuming).")]
#[must_use]
#[inline]
pub fn $with(mut self, value: $ty) -> Self {
self.$field = Some(value);
self
}
#[doc = concat!("Set `", stringify!($field), "` to `Some(value)` (in place).")]
#[inline]
pub fn $set(&mut self, value: $ty) -> &mut Self {
self.$field = Some(value);
self
}
#[doc = concat!("Assign the raw `", stringify!($field), "` option (consuming).")]
#[must_use]
#[inline]
pub fn $maybe(mut self, value: Option<$ty>) -> Self {
self.$field = value;
self
}
#[doc = concat!("Assign the raw `", stringify!($field), "` option (in place).")]
#[inline]
pub fn $update(&mut self, value: Option<$ty>) -> &mut Self {
self.$field = value;
self
}
};
}
pub(crate) use opt_accessor;
macro_rules! to_filter {
(@ $family:ident, $marker:ident, $ty:ty => $filter:ty, vec = $vec:ty) => {
impl $crate::$family for $ty {
type Filter = $filter;
}
impl $crate::DefaultMarker for $ty {
type Marker = $crate::$marker<$ty>;
}
impl $crate::DefaultVecMarker for $ty {
type Marker = $vec;
}
};
(@ $family:ident, $marker:ident, $ty:ty => $filter:ty) => {
to_filter!(@ $family, $marker, $ty => $filter, vec = $crate::ListMarker<::std::vec::Vec<$ty>>);
};
($ty:ty as scalar => $filter:ty $(, vec = $vec:ty)?) => {
to_filter!(@ ScalarFilterMarker, ScalarMarker, $ty => $filter $(, vec = $vec)?);
};
($ty:ty as string => $filter:ty $(, vec = $vec:ty)?) => {
to_filter!(@ StringFilterMarker, StringMarker, $ty => $filter $(, vec = $vec)?);
};
($ty:ty as bytes => $filter:ty $(, vec = $vec:ty)?) => {
to_filter!(@ BytesFilterMarker, BytesMarker, $ty => $filter $(, vec = $vec)?);
};
($ty:ty as bool => $filter:ty $(, vec = $vec:ty)?) => {
to_filter!(@ BoolFilterMarker, BoolMarker, $ty => $filter $(, vec = $vec)?);
};
($ty:ty as duration => $filter:ty $(, vec = $vec:ty)?) => {
to_filter!(@ DurationFilterMarker, DurationMarker, $ty => $filter $(, vec = $vec)?);
};
}
#[cfg(feature = "async-graphql")]
#[doc(hidden)]
#[macro_export]
macro_rules! __ingraph_filter_input_fields {
($registry:ident, $( $name:literal : $fty:ty ),+ $(,)?) => {{
let mut fields = $crate::__private::async_graphql::indexmap::IndexMap::new();
$(
fields.insert(
::std::string::String::from($name),
$crate::__private::async_graphql::registry::MetaInputValue {
name: ::std::string::String::from($name),
description: ::std::option::Option::None,
ty: <$fty as $crate::__private::async_graphql::InputType>::create_type_info($registry),
deprecation: $crate::__private::async_graphql::registry::Deprecation::NoDeprecated,
default_value: ::std::option::Option::None,
visible: ::std::option::Option::None,
inaccessible: false,
tags: ::std::vec::Vec::new(),
is_secret: false,
directive_invocations: ::std::vec::Vec::new(),
},
);
)+
fields
}};
}
#[cfg(feature = "async-graphql")]
#[doc(hidden)]
#[macro_export]
macro_rules! __ingraph_filter_value_map {
($owner:expr, $( $name:literal : $field:ident ),+ $(,)?) => {{
let mut map = $crate::__private::async_graphql::indexmap::IndexMap::new();
$(
map.insert(
$crate::__private::async_graphql::Name::new($name),
$crate::__private::async_graphql::InputType::to_value(&$owner.$field),
);
)+
map
}};
}
#[cfg(feature = "async-graphql")]
#[macro_export]
macro_rules! filter_input_object {
(
$filter:ty : $gql:literal {
bare $bare:ident : $bfty:ty => $bname:literal
$(, $field:ident : $fty:ty => $name:literal )* $(,)?
}
) => {
impl $crate::__private::async_graphql::InputType for $filter {
type RawValueType = Self;
#[inline]
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed($gql)
}
fn create_type_info(
registry: &mut $crate::__private::async_graphql::registry::Registry,
) -> ::std::string::String {
registry.create_input_type::<Self, _>(
$crate::__private::async_graphql::registry::MetaTypeId::InputObject,
|registry| $crate::__private::async_graphql::registry::MetaType::InputObject {
name: ::std::string::String::from($gql),
description: ::std::option::Option::None,
input_fields: <Self as $crate::NullableFace>::bare_fields(registry),
visible: ::std::option::Option::None,
inaccessible: false,
tags: ::std::vec::Vec::new(),
rust_typename: ::std::option::Option::Some(::std::any::type_name::<Self>()),
oneof: false,
directive_invocations: ::std::vec::Vec::new(),
},
)
}
fn parse(
value: ::std::option::Option<$crate::__private::async_graphql::Value>,
) -> $crate::__private::async_graphql::InputValueResult<Self> {
match $crate::sent(value) {
$crate::Sent::Longhand(obj) => {
let $bare = <$bfty as $crate::__private::async_graphql::InputType>::parse(obj.get($bname).cloned())
.map_err($crate::__private::async_graphql::InputValueError::propagate)?;
$(
let $field = <$fty as $crate::__private::async_graphql::InputType>::parse(obj.get($name).cloned())
.map_err($crate::__private::async_graphql::InputValueError::propagate)?;
)*
::std::result::Result::Ok(Self { $bare, $( $field, )* })
}
$crate::Sent::Bare(__ingraph_bare) => {
let $bare = <$bfty as $crate::__private::async_graphql::InputType>::parse(
::std::option::Option::Some(__ingraph_bare),
)
.map_err($crate::__private::async_graphql::InputValueError::propagate)?;
::std::result::Result::Ok(Self {
$bare,
..<Self as ::core::default::Default>::default()
})
}
$crate::Sent::Null => {
::std::result::Result::Err($crate::__private::async_graphql::InputValueError::expected_type(
$crate::__private::async_graphql::Value::Null,
))
}
$crate::Sent::Refused(__ingraph_sent) => {
::std::result::Result::Err($crate::__private::async_graphql::InputValueError::expected_type(
__ingraph_sent,
))
}
}
}
fn to_value(&self) -> $crate::__private::async_graphql::Value {
$crate::__private::async_graphql::Value::Object(<Self as $crate::NullableFace>::bare_values(self))
}
#[inline]
fn as_raw_value(&self) -> ::std::option::Option<&Self::RawValueType> {
::std::option::Option::Some(self)
}
}
impl $crate::__private::async_graphql::InputObjectType for $filter {}
impl $crate::NullableFace for $filter {
fn bare_fields(
registry: &mut $crate::__private::async_graphql::registry::Registry,
) -> $crate::__private::async_graphql::indexmap::IndexMap<
::std::string::String,
$crate::__private::async_graphql::registry::MetaInputValue,
> {
$crate::__ingraph_filter_input_fields!(registry, $bname : $bfty $(, $name : $fty )*)
}
fn bare_values(
&self,
) -> $crate::__private::async_graphql::indexmap::IndexMap<$crate::__private::async_graphql::Name, $crate::__private::async_graphql::Value> {
$crate::__ingraph_filter_value_map!(self, $bname : $bare $(, $name : $field )*)
}
}
};
}
#[cfg(feature = "async-graphql")]
#[macro_export]
macro_rules! via_filter_input_object {
(
$filter:ty : $gql:literal via $wire:ty {
$( $field:ident => $name:literal ),+ $(,)?
;
$( $list:ident => $list_name:literal ),* $(,)?
}
) => {
impl $crate::__private::async_graphql::InputType for $filter {
type RawValueType = Self;
#[inline]
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed($gql)
}
fn create_type_info(
registry: &mut $crate::__private::async_graphql::registry::Registry,
) -> ::std::string::String {
registry.create_input_type::<Self, _>(
$crate::__private::async_graphql::registry::MetaTypeId::InputObject,
|registry| $crate::__private::async_graphql::registry::MetaType::InputObject {
name: ::std::string::String::from($gql),
description: ::std::option::Option::None,
input_fields: <Self as $crate::NullableFace>::bare_fields(registry),
visible: ::std::option::Option::None,
inaccessible: false,
tags: ::std::vec::Vec::new(),
rust_typename: ::std::option::Option::Some(::std::any::type_name::<Self>()),
oneof: false,
directive_invocations: ::std::vec::Vec::new(),
},
)
}
fn parse(
value: ::std::option::Option<$crate::__private::async_graphql::Value>,
) -> $crate::__private::async_graphql::InputValueResult<Self> {
match $crate::sent(value) {
$crate::Sent::Longhand(object) => {
let mut filter = <Self as ::core::default::Default>::default();
$( filter.$field = $crate::__private::graphql::filter::via::read::<$wire, _, Self>(&object, $name)?; )+
$( filter.$list = $crate::__private::graphql::filter::via::read_list::<$wire, _, Self>(&object, $list_name)?; )*
::std::result::Result::Ok(filter)
}
$crate::Sent::Bare(__ingraph_bare) => {
let mut __ingraph_object = $crate::__private::async_graphql::indexmap::IndexMap::new();
__ingraph_object.insert(
$crate::__private::async_graphql::Name::new($crate::__ingraph_first!($( $name ),+)),
__ingraph_bare,
);
let mut filter = <Self as ::core::default::Default>::default();
$( filter.$field =
$crate::__private::graphql::filter::via::read::<$wire, _, Self>(&__ingraph_object, $name)?; )+
::std::result::Result::Ok(filter)
}
$crate::Sent::Null => {
::std::result::Result::Err($crate::__private::async_graphql::InputValueError::expected_type(
$crate::__private::async_graphql::Value::Null,
))
}
$crate::Sent::Refused(__ingraph_sent) => {
::std::result::Result::Err($crate::__private::async_graphql::InputValueError::expected_type(
__ingraph_sent,
))
}
}
}
fn to_value(&self) -> $crate::__private::async_graphql::Value {
$crate::__private::async_graphql::Value::Object(<Self as $crate::NullableFace>::bare_values(self))
}
#[inline]
fn as_raw_value(&self) -> ::std::option::Option<&Self::RawValueType> {
::std::option::Option::Some(self)
}
}
impl $crate::__private::async_graphql::InputObjectType for $filter {}
impl $crate::NullableFace for $filter {
fn bare_fields(
registry: &mut $crate::__private::async_graphql::registry::Registry,
) -> $crate::__private::async_graphql::indexmap::IndexMap<
::std::string::String,
$crate::__private::async_graphql::registry::MetaInputValue,
> {
$crate::__ingraph_filter_input_fields!(
registry,
$( $name : ::core::option::Option<$wire>, )+
$( $list_name : ::core::option::Option<::std::boxed::Box<[$wire]>> ),*
)
}
fn bare_values(
&self,
) -> $crate::__private::async_graphql::indexmap::IndexMap<$crate::__private::async_graphql::Name, $crate::__private::async_graphql::Value> {
let mut map = $crate::__private::async_graphql::indexmap::IndexMap::new();
$(
map.insert(
$crate::__private::async_graphql::Name::new($name),
$crate::__private::graphql::filter::via::write::<$wire, _>(&self.$field),
);
)+
$(
map.insert(
$crate::__private::async_graphql::Name::new($list_name),
$crate::__private::graphql::filter::via::write_list::<$wire, _>(&self.$list),
);
)*
map
}
}
};
}
mod boolean;
mod bytes;
mod confidence;
#[cfg(any(feature = "jiff", feature = "async-graphql"))]
mod duration;
mod r#enum;
#[cfg(feature = "flags")]
mod flags;
#[cfg(feature = "async-graphql")]
#[doc(hidden)]
pub mod flatten;
mod list;
mod nullable;
mod quantified;
mod reference;
mod related;
mod scalar;
mod set;
mod slot;
#[cfg(any(feature = "jiff", feature = "async-graphql"))]
pub(crate) mod temporal;
#[cfg(test)]
mod tests;
mod text;
#[cfg(feature = "async-graphql")]
#[doc(hidden)]
pub mod via;
pub use boolean::*;
pub use bytes::*;
#[cfg(feature = "mongo")]
pub(crate) use bytes::ByteOperands;
#[cfg(any(feature = "mongo", feature = "sqlx"))]
pub(crate) use bytes::ByteSlots;
pub use confidence::*;
#[cfg(any(feature = "jiff", feature = "async-graphql"))]
pub use duration::*;
pub use r#enum::*;
#[cfg(feature = "flags")]
pub use flags::*;
#[cfg(feature = "async-graphql")]
pub use flatten::FlattenFace;
pub use list::*;
pub use nullable::*;
pub use quantified::*;
pub use reference::*;
pub use related::*;
pub use scalar::*;
pub use set::*;
pub use slot::*;
#[cfg(any(feature = "jiff", feature = "async-graphql"))]
pub use temporal::{JiffCivilDateTime, JiffZoneOffset};
pub use text::*;
pub trait GraphqlFilter {
fn is_empty(&self) -> bool;
}
pub trait TryMapFilter<D, V> {
type Mapped;
fn try_map_filter<E, F>(self, f: F) -> Result<Self::Mapped, E>
where
F: FnMut(D) -> Result<V, E>;
}
pub trait EqualsFilter<T> {
#[must_use]
fn equals(value: T) -> Self;
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ingraph_first {
($head:literal $(, $rest:literal )*) => {
$head
};
}
#[cfg(feature = "async-graphql")]
pub enum Sent {
Longhand(async_graphql::indexmap::IndexMap<async_graphql::Name, async_graphql::Value>),
Bare(async_graphql::Value),
Null,
Refused(async_graphql::Value),
}
#[cfg(feature = "async-graphql")]
pub fn sent(value: Option<async_graphql::Value>) -> Sent {
match value {
Some(async_graphql::Value::Object(object)) => Sent::Longhand(object),
Some(async_graphql::Value::Null) => Sent::Null,
Some(list @ async_graphql::Value::List(_)) => Sent::Refused(list),
Some(bare) => Sent::Bare(bare),
None => Sent::Refused(async_graphql::Value::Null),
}
}
#[cfg(feature = "async-graphql")]
pub fn shorthand<F>(
bare: async_graphql::Value,
) -> async_graphql::indexmap::IndexMap<async_graphql::Name, async_graphql::Value>
where
F: NullableFace,
{
let mut object = async_graphql::indexmap::IndexMap::new();
if let Some(first) = F::default().bare_values().into_keys().next() {
object.insert(first, bare);
}
object
}
#[cfg(feature = "async-graphql")]
pub fn refuse_bare<F>(sent: &async_graphql::Value) -> async_graphql::InputValueError<F>
where
F: NullableFace,
{
let rendered = F::default().bare_values();
let names = rendered
.keys()
.map(async_graphql::Name::as_str)
.collect::<std::vec::Vec<_>>();
let face = <F as async_graphql::InputType>::type_name();
async_graphql::InputValueError::custom(match names.split_last() {
None => std::format!("a `{face}` takes an object — not a bare {sent}"),
Some((last, [])) => {
std::format!("a `{face}` names the operator it asks: {last} — not a bare {sent}")
}
Some((last, rest)) => std::format!(
"a `{face}` names the operator it asks: one of {listed} or {last} — not a bare {sent}",
listed = rest.join(", "),
),
})
}
#[cfg(feature = "async-graphql")]
#[inline]
pub(crate) fn parse_slot<V, F>(
object: &async_graphql::indexmap::IndexMap<async_graphql::Name, async_graphql::Value>,
name: &str,
) -> Result<V, async_graphql::InputValueError<F>>
where
V: async_graphql::InputType,
F: async_graphql::InputType,
{
via::nested(object, name)
}
#[cfg(feature = "async-graphql")]
pub(crate) fn operand_of(filter: &str) -> &str {
filter.strip_suffix("Filter").unwrap_or(filter)
}
pub(crate) fn map_operand<T, U, E>(
slot: Option<T>,
f: &mut impl FnMut(T) -> Result<U, E>,
) -> Result<Option<U>, E> {
match slot {
Some(value) => f(value).map(Some),
None => Ok(None),
}
}
pub(crate) fn map_operands<T, U, E>(
slot: Option<Box<[T]>>,
f: &mut impl FnMut(T) -> Result<U, E>,
) -> Result<Option<Box<[U]>>, E> {
match slot {
Some(values) => {
let mut mapped = Vec::with_capacity(values.len());
for value in values {
mapped.push(f(value)?);
}
Ok(Some(mapped.into_boxed_slice()))
}
None => Ok(None),
}
}
to_filter!(bool as bool => BooleanFilter);
to_filter!(i8 as scalar => ScalarFilter<i8>);
to_filter!(i16 as scalar => ScalarFilter<i16>);
to_filter!(i32 as scalar => ScalarFilter<i32>);
to_filter!(i64 as scalar => ScalarFilter<i64>);
to_filter!(i128 as scalar => ScalarFilter<i128>);
to_filter!(u8 as scalar => ScalarFilter<u8>, vec = BytesMarker<Vec<u8>>);
to_filter!(u16 as scalar => ScalarFilter<u16>);
to_filter!(u32 as scalar => ScalarFilter<u32>);
to_filter!(u64 as scalar => ScalarFilter<u64>);
to_filter!(u128 as scalar => ScalarFilter<u128>);
to_filter!(f32 as scalar => ScalarFilter<f32>);
to_filter!(f64 as scalar => ScalarFilter<f64>);
to_filter!(::core::num::NonZeroI8 as scalar => ScalarFilter<::core::num::NonZeroI8>);
to_filter!(::core::num::NonZeroI16 as scalar => ScalarFilter<::core::num::NonZeroI16>);
to_filter!(::core::num::NonZeroI32 as scalar => ScalarFilter<::core::num::NonZeroI32>);
to_filter!(::core::num::NonZeroI64 as scalar => ScalarFilter<::core::num::NonZeroI64>);
to_filter!(::core::num::NonZeroI128 as scalar => ScalarFilter<::core::num::NonZeroI128>);
to_filter!(::core::num::NonZeroU8 as scalar => ScalarFilter<::core::num::NonZeroU8>);
to_filter!(::core::num::NonZeroU16 as scalar => ScalarFilter<::core::num::NonZeroU16>);
to_filter!(::core::num::NonZeroU32 as scalar => ScalarFilter<::core::num::NonZeroU32>);
to_filter!(::core::num::NonZeroU64 as scalar => ScalarFilter<::core::num::NonZeroU64>);
to_filter!(::core::num::NonZeroU128 as scalar => ScalarFilter<::core::num::NonZeroU128>);
to_filter!(::std::net::Ipv4Addr as scalar => ScalarFilter<::std::net::Ipv4Addr>);
to_filter!(::std::net::Ipv6Addr as scalar => ScalarFilter<::std::net::Ipv6Addr>);
to_filter!(::std::net::IpAddr as scalar => ScalarFilter<::std::net::IpAddr>);
to_filter!(::std::net::SocketAddrV4 as scalar => ScalarFilter<::std::net::SocketAddrV4>);
to_filter!(::std::net::SocketAddrV6 as scalar => ScalarFilter<::std::net::SocketAddrV6>);
to_filter!(::std::net::SocketAddr as scalar => ScalarFilter<::std::net::SocketAddr>);
to_filter!(::uuid::Uuid as scalar => ScalarFilter<::uuid::Uuid>);
#[cfg(feature = "regex")]
to_filter!(::regex::Regex as scalar => ScalarFilter<::regex::Regex>);
to_filter!(String as string => TextFilter<String>);
impl BytesFilterMarker for Vec<u8> {
type Filter = BytesFilter<Vec<u8>>;
}
impl DefaultVecMarker for Vec<u8> {
type Marker = ListMarker<Vec<Vec<u8>>>;
}
impl<S: crate::ConfidenceCarrier> crate::ScalarFilterMarker for Confidence<S> {
type Filter = ConfidenceFilter;
}
impl<S: crate::ConfidenceCarrier> DefaultMarker for Confidence<S> {
type Marker = crate::ScalarMarker<Confidence<S>>;
}
impl<S: crate::ConfidenceCarrier> DefaultVecMarker for Confidence<S> {
type Marker = ListMarker<Vec<Confidence<S>>>;
}
to_filter!(Timestamp as scalar => ScalarFilter<Timestamp>);
to_filter!(Count as scalar => ScalarFilter<Count>);
#[cfg(feature = "smol_str")]
to_filter!(smol_str::SmolStr as string => TextFilter<smol_str::SmolStr>);
to_filter!(::bytes::Bytes as bytes => BytesFilter<::bytes::Bytes>);
to_filter!(smol_bytes::Bytes as bytes => BytesFilter<smol_bytes::Bytes>);
to_filter!(smol_bytes::Utf8Bytes as string => TextFilter<smol_bytes::Utf8Bytes>);
#[cfg(feature = "jiff")]
to_filter!(jiff::Timestamp as scalar => ScalarFilter<jiff::Timestamp>);
#[cfg(feature = "jiff")]
to_filter!(jiff::civil::Date as scalar => ScalarFilter<jiff::civil::Date>);
#[cfg(feature = "jiff")]
to_filter!(jiff::civil::Time as scalar => ScalarFilter<jiff::civil::Time>);
#[cfg(feature = "jiff")]
to_filter!(jiff::Zoned as scalar => ScalarFilter<jiff::Zoned>);
#[cfg(feature = "jiff")]
to_filter!(jiff::civil::DateTime as scalar => ScalarFilter<jiff::civil::DateTime>);
#[cfg(feature = "jiff")]
to_filter!(jiff::tz::Offset as scalar => ScalarFilter<jiff::tz::Offset>);
#[cfg(feature = "jiff")]
to_filter!(jiff::SignedDuration as duration => DurationFilter);
impl<const N: usize> BytesFilterMarker for [u8; N] {
type Filter = FixedBytesFilter<[u8; N], N>;
}
impl<const N: usize> DefaultMarker for [u8; N] {
type Marker = BytesMarker<[u8; N]>;
}
impl<const N: usize> DefaultVecMarker for [u8; N] {
type Marker = ListMarker<Vec<[u8; N]>>;
}
#[cfg(feature = "async-graphql")]
#[async_graphql::Scalar(
name = "Timestamp",
specified_by_url = "https://datatracker.ietf.org/doc/html/rfc3339"
)]
impl async_graphql::ScalarType for Timestamp {
fn parse(value: async_graphql::Value) -> async_graphql::InputValueResult<Self> {
match &value {
async_graphql::Value::String(text) => {
text.parse().map_err(async_graphql::InputValueError::custom)
}
_ => Err(async_graphql::InputValueError::expected_type(value)),
}
}
#[inline]
fn is_valid(value: &async_graphql::Value) -> bool {
matches!(value, async_graphql::Value::String(text) if text.parse::<Timestamp>().is_ok())
}
fn to_value(&self) -> async_graphql::Value {
async_graphql::Value::String(self.to_string())
}
}
#[cfg(feature = "async-graphql")]
filter_input_object!(BooleanFilter : "BooleanFilter" {
bare eq: ::core::option::Option<bool> => "eq",
ne: ::core::option::Option<bool> => "ne",
in_: ::core::option::Option<::std::boxed::Box<[bool]>> => "in",
not_in: ::core::option::Option<::std::boxed::Box<[bool]>> => "notIn",
});