#[non_exhaustive]pub struct TableObjectType {
pub table: Table,
pub name: String,
pub local_name: String,
pub fields: Vec<GraphQLField>,
pub writable_fields: Vec<GraphQLField>,
pub description: Option<String>,
}Expand description
Represents a GraphQL ObjectType derived from a database table.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.table: TableThe original table.
name: StringGraphQL type name (PascalCase).
local_name: StringBase name for generated helper types owned by this table.
fields: Vec<GraphQLField>Fields derived from columns: the ones a read may name.
Empty where the role may write this table and not read it, which is a
table with no GraphQL type – see crate::role.
writable_fields: Vec<GraphQLField>Fields a write may name, before the write permission narrows them.
The same list before the read permission was applied, which is what
makes a column a role may set without seeing expressible: fields is
what the type shows and this is what the insert and update inputs are
built from. Equal to fields where nothing narrowed them.
description: Option<String>The type’s description: the table’s comment, or the one metadata gave
instead. Some("") is a description that was given and is empty, which
is how metadata says the type has none.
Implementations§
Source§impl TableObjectType
impl TableObjectType
Sourcepub fn from_table(table: &Table) -> Self
pub fn from_table(table: &Table) -> Self
Create a GraphQL ObjectType from a database table.
The type is named after the table. Use Self::from_table_named when
the name must be disambiguated (for example when the same table name
appears in more than one exposed schema).
Sourcepub fn from_table_named(
table: &Table,
base_name: &str,
names: &NameOverrides,
) -> Self
pub fn from_table_named( table: &Table, base_name: &str, names: &NameOverrides, ) -> Self
Build the field for a table, under a name chosen by the caller.
Separate from the unnamed constructor because a custom table name has to reach the field before its type name is derived from it.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Get the description from table comment.
Sourcepub fn table_name(&self) -> &str
pub fn table_name(&self) -> &str
The name of the table itself, which is not always the type’s: a configured base name renames the type and leaves the table alone.
Sourcepub fn fields(&self) -> &[GraphQLField]
pub fn fields(&self) -> &[GraphQLField]
Get all fields.
Sourcepub fn get_field(&self, name: &str) -> Option<&GraphQLField>
pub fn get_field(&self, name: &str) -> Option<&GraphQLField>
Get a field by name.
Sourcepub fn pk_fields(&self) -> Vec<&GraphQLField>
pub fn pk_fields(&self) -> Vec<&GraphQLField>
Get primary key fields.
Trait Implementations§
Source§impl Clone for TableObjectType
impl Clone for TableObjectType
Auto Trait Implementations§
impl Freeze for TableObjectType
impl RefUnwindSafe for TableObjectType
impl Send for TableObjectType
impl Sync for TableObjectType
impl Unpin for TableObjectType
impl UnsafeUnpin for TableObjectType
impl UnwindSafe for TableObjectType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more