pub struct TableNames {
pub name: Option<String>,
pub relationships: HashMap<String, String>,
pub declared_relationships: Option<Vec<DeclaredRelationship>>,
pub computed_fields: HashMap<String, String>,
pub roots: HashMap<String, String>,
pub comments: Comments,
pub columns: HashMap<String, String>,
pub is_enum: bool,
pub permissions: HashMap<String, RolePermissions>,
}Expand description
The names given to one table.
Fields§
§name: Option<String>The base name for this table’s root fields and types.
"name": "Author" gives Author, Author_by_pk, insert_Author,
Author_bool_exp and the rest, since all of them are derived from one
base name.
relationships: HashMap<String, String>Relationship field names, keyed by constraint name – or by function name for a computed relationship, which has no constraint.
declared_relationships: Option<Vec<DeclaredRelationship>>The relationships this table has, where metadata says which.
relationships above renames what reflection found; this replaces it.
Two things need that, and they are the same thing seen from either end.
A manual relationship maps column to column and has no constraint
to be keyed by, so relationships cannot carry it at all – and a
permission written through one could not be compiled, which is a read
refused rather than narrowed.
And which relationships exist is metadata’s to say. Reflection offers one per foreign key; Hasura offers the ones its metadata declares, which is usually fewer. A table whose keys are all declared looks the same either way, and one that tracks only some of them does not.
Absent means “reflect”, which is what a document that says nothing about a table has always meant. Present means “these, and no others”.
computed_fields: HashMap<String, String>Computed field names, keyed by the function behind them.
roots: HashMap<String, String>Root field names, keyed by the root they replace: select,
select_by_pk, select_aggregate, insert, insert_one, update,
update_by_pk, delete, delete_by_pk.
Separate from name because Hasura names each root independently –
select: Authors, select_by_pk: Author, select_aggregate: AuthorAgg – where a base name derives all of them from one word. A
set that agrees on a base could be written as name; one that does not
can only be written here.
comments: CommentsDescriptions Hasura keeps in metadata rather than in the database.
A comment is not a name, and is here for the same reason the names are:
where metadata carries one, the database’s own comment is not what a
client sees. An empty string is “no description”, which is how
set_table_customization suppresses a comment the database has.
columns: HashMap<String, String>Field names for columns, keyed by the column.
The one rename that is not a name for something derived: a column has a
name, and this is a different one to expose it under. It reaches
further than the others because a column appears in the projection, in
where, in order_by, in distinct_on, in both mutation inputs and
in every embed – everywhere a field name has to become SQL.
is_enum: boolWhether this table is a set of allowed values rather than a set of rows.
The one thing here that is not a name, and it is here for the same
reason the names are: nothing in the schema says it. A table with a
text primary key and a comment column is an ordinary table – being an
enumeration is a decision someone made about it, which Hasura records
as set_table_is_enum and which reflection cannot recover.
Marked so, its rows become the members of a GraphQL enum and every column with a foreign key to it is typed as that enum instead of as text.
permissions: HashMap<String, RolePermissions>What each role may do with this table, keyed by role.
A role absent from this map has no permission on the table at all,
which in Hasura is not a refusal at execution but an absence in the
schema: the root fields are not there to be named. The same is true one
level down – a role with select and no insert has no insert_x
field, and asking for one is a validation failure rather than a denial.
Empty for every table until a document says otherwise, and a document that says nothing about permissions leaves the server behaving as it did before they existed: database roles and row level security, with no second layer above them.
Trait Implementations§
Source§impl Clone for TableNames
impl Clone for TableNames
Source§fn clone(&self) -> TableNames
fn clone(&self) -> TableNames
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableNames
impl Debug for TableNames
Source§impl Default for TableNames
impl Default for TableNames
Source§fn default() -> TableNames
fn default() -> TableNames
Source§impl<'de> Deserialize<'de> for TableNames
impl<'de> Deserialize<'de> for TableNames
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for TableNames
impl PartialEq for TableNames
Source§impl Serialize for TableNames
impl Serialize for TableNames
impl StructuralPartialEq for TableNames
Auto Trait Implementations§
impl Freeze for TableNames
impl RefUnwindSafe for TableNames
impl Send for TableNames
impl Sync for TableNames
impl Unpin for TableNames
impl UnsafeUnpin for TableNames
impl UnwindSafe for TableNames
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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