Skip to main content

TableNames

Struct TableNames 

Source
#[non_exhaustive]
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 column_types: HashMap<String, ColumnTypeOverride>, pub is_enum: bool, pub federation: FederationConfig, pub permissions: HashMap<String, RolePermissions>, }
Expand description

The names given to one table.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§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: Comments

Descriptions 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.

§column_types: HashMap<String, ColumnTypeOverride>

GraphQL scalar overrides for columns, keyed by the database column.

PostgreSQL has no ID type: identifiers are commonly stored as text, integers or UUIDs. This lets the public GraphQL contract mark a column as an opaque identifier without changing the type used to read, bind or cast that column in PostgreSQL.

§is_enum: bool

Whether 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.

§federation: FederationConfig

Apollo Federation settings for this table.

§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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableNames

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TableNames

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TableNames

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TableNames

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TableNames

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TableNames

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more