use serde::{Deserialize, Serialize};
use super::super::query::CompoundQuery;
#[cfg(feature = "graphql")]
use super::super::query::CompoundQueryInput;
#[cfg(feature = "graphql")]
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
#[derive(async_graphql::InputObject, Serialize, Clone, Debug)]
#[graphql(name = "NestedFilterInput")]
#[cfg_attr(feature = "builder", builder(field_defaults(setter(into))))]
pub struct NestedQueryInput {
pub path: String,
pub query: CompoundQueryInput,
#[graphql(default)]
#[cfg_attr(feature = "builder", builder(default))]
pub ignore_unmapped: bool,
}
#[cfg(feature = "graphql")]
impl NestedQueryInput {
#[inline]
pub fn new(
path: impl Into<String>,
query: impl Into<CompoundQueryInput>,
ignore_unmapped: bool,
) -> NestedQueryInput {
NestedQueryInput {
path: path.into(),
query: query.into(),
ignore_unmapped,
}
}
}
#[cfg(feature = "graphql")]
impl From<NestedQuery> for NestedQueryInput {
#[inline]
fn from(query: NestedQuery) -> Self {
Self {
path: query.path,
query: query.query.into(),
ignore_unmapped: query.ignore_unmapped,
}
}
}
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
#[cfg_attr(feature = "graphql", graphql(name = "NestedFilter"))]
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
#[derive(Serialize, Deserialize, Clone, Debug)]
#[cfg_attr(feature = "builder", builder(field_defaults(setter(into))))]
pub struct NestedQuery {
pub path: String,
pub query: CompoundQuery,
#[cfg_attr(feature = "builder", builder(default))]
pub ignore_unmapped: bool,
}
impl NestedQuery {
#[inline]
pub fn new(
path: impl Into<String>,
query: impl Into<CompoundQuery>,
ignore_unmapped: bool,
) -> NestedQuery {
NestedQuery {
path: path.into(),
query: query.into(),
ignore_unmapped,
}
}
}
#[cfg(feature = "graphql")]
impl From<NestedQueryInput> for NestedQuery {
#[inline]
fn from(input: NestedQueryInput) -> NestedQuery {
NestedQuery {
path: input.path,
query: input.query.into(),
ignore_unmapped: input.ignore_unmapped,
}
}
}