[−][src]Struct juniper_eager_loading::HasOne
A non-optional "has one" association.
Imagine you have these models:
struct User { id: i32, country_id: i32, } struct Country { id: i32, }
For this setup we say "a user has one country". This means that User
has a field named
country_id
that references the id of another country.
Example
You can find a complete example of HasOne
here.
Attributes
Name | Description | Default | Example |
---|---|---|---|
foreign_key_field | The name of the foreign key field | {name of field}_id | foreign_key_field = country_id |
root_model_field | The name of the field on the associated GraphQL type that holds the model | {name of field} | root_model_field = country |
graphql_field | The name of this field in your GraphQL schema | {name of field} | graphql_field = country |
child_primary_key_field | The name of the primary key field on the associated model | id | child_primary_key_field = identifier |
default | Use the default value for all unspecified attributes | N/A | default |
Additionally it also supports the attributes print
, skip
, and field_arguments
. See the root model
docs for more into on those.
Errors
When calling try_unwrap
to get the loaded value it will return an error if the value has
not been loaded, or if the load failed.
For example if a user has a country_id
of 10
but there is no Country
with id 10
then
try_unwrap
will return an error.
Methods
impl<T> HasOne<T>
[src]
pub fn try_unwrap(&self) -> Result<&T, Error>
[src]
Borrow the loaded value. If the value has not been loaded it will return an error.
Trait Implementations
impl<T> Association<T> for HasOne<T>
[src]
fn loaded_child(&mut self, child: T)
[src]
fn assert_loaded_otherwise_failed(&mut self)
[src]
impl<T> Association<T> for HasOne<Box<T>>
[src]
fn loaded_child(&mut self, child: T)
[src]
fn assert_loaded_otherwise_failed(&mut self)
[src]
impl<T: Clone> Clone for HasOne<T>
[src]
impl<T: Debug> Debug for HasOne<T>
[src]
impl<T> Default for HasOne<T>
[src]
impl<T: Eq> Eq for HasOne<T>
[src]
impl<T: Ord> Ord for HasOne<T>
[src]
fn cmp(&self, other: &HasOne<T>) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<HasOne<T>> for HasOne<T>
[src]
impl<T: PartialOrd> PartialOrd<HasOne<T>> for HasOne<T>
[src]
fn partial_cmp(&self, other: &HasOne<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &HasOne<T>) -> bool
[src]
fn le(&self, other: &HasOne<T>) -> bool
[src]
fn gt(&self, other: &HasOne<T>) -> bool
[src]
fn ge(&self, other: &HasOne<T>) -> bool
[src]
impl<T> StructuralEq for HasOne<T>
[src]
impl<T> StructuralPartialEq for HasOne<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for HasOne<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for HasOne<T> where
T: Send,
T: Send,
impl<T> Sync for HasOne<T> where
T: Sync,
T: Sync,
impl<T> Unpin for HasOne<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for HasOne<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,