Skip to main content

NameOverrides

Struct NameOverrides 

Source
pub struct NameOverrides { /* private fields */ }
Expand description

Every name given, keyed by schema.table.

Implementations§

Source§

impl NameOverrides

Source

pub fn parse(value: &str) -> Result<Self, String>

Read from JSON: either the document itself, or a path to a file holding it.

Told apart by the first non-space character, because a JSON object cannot begin with anything but { and a path cannot begin with it. Both spellings exist because both places are natural: a handful of names belongs in the environment beside every other setting, and a migrated schema’s worth of them belongs in a file under review.

Source

pub fn is_empty(&self) -> bool

Whether any name was given at all.

Source

pub fn exposed_as(&self, schema: &str, function: &str) -> Option<&str>

Which root a function was placed on, if metadata said.

query or mutation. Reflection places a function by its volatility, which is the only thing the catalogue records; Hasura lets metadata override it – track_function with configuration: {exposed_as: query} puts a VOLATILE function on the query root, which is a thing a person decided and no schema remembers.

Source

pub fn function_grants(&self, schema: &str, function: &str, role: &str) -> bool

Whether a role was granted this function by a function permission.

Only asked of a function exposed as a mutation – see FunctionNames for why the query side is inferred instead.

Source

pub fn declared_relationships( &self, schema: &str, table: &str, ) -> Option<&[DeclaredRelationship]>

The relationships metadata declares for a table, where it declares any.

Source

pub fn len(&self) -> usize

How many tables were named, for the line the server logs at startup.

Source

pub fn placed_functions(&self) -> usize

How many functions were placed, for the same line.

Source

pub fn permissions( &self, schema: &str, table: &str, role: &str, ) -> Option<&RolePermissions>

What one role may do with one table.

None means the role was named nothing about this table, which is not the same as being named an empty permission: the first has no access, the second has access to nothing. Both refuse, and only the second is a decision someone wrote down.

Source

pub fn tables_with_permissions<'a>( &'a self, role: &'a str, ) -> impl Iterator<Item = &'a RolePermissions> + 'a

What one role was granted, across every table that grants it anything.

Source

pub fn introspection_disabled(&self, role: &str) -> bool

Whether this role may read the schema as data.

__typename is not this question: it names the type of a row a client is already reading, every client library sends it, and Hasura answers it for a role introspection is disabled for. __schema and __type are the two that read the schema itself.

Source

pub fn has_permissions(&self) -> bool

Whether the document says anything about permissions at all.

The switch for the whole layer. A document carrying only names leaves the server as it was: database roles and row level security, with nothing above them. One permission anywhere turns the layer on for every table, because a document that grants user a filtered view of article and says nothing about author is saying user cannot read author – not that author is open to everyone.

Source

pub fn roles(&self) -> Vec<&str>

Every role the document names, sorted.

Sorted because a schema is built per role and the order they are built in should not depend on how a hash map felt. admin is not among them unless a permission names it: an administrator is not a role with permissions but a caller the permissions do not apply to.

Source

pub fn granted(&self) -> usize

How many table-and-role pairs were granted something, for the line the server logs at startup.

Source

pub fn is_enum(&self, schema: &str, table: &str) -> bool

Whether a table was marked as a set of allowed values.

Source

pub fn enum_tables(&self) -> Vec<(String, String)>

Every table marked as one, as (schema, table).

Source

pub fn base_name(&self, schema: &str, table: &str) -> Option<&str>

The base name given to a table, if one was.

Source

pub fn relationship( &self, schema: &str, table: &str, source: &str, ) -> Option<&str>

The name given to a relationship, by its constraint, column or function.

Falls back to computed_fields because Hasura has one command for both: add_computed_field covers a function returning a value and a function returning rows, and which it is cannot be told from the metadata – only from the database. A converter should not have to connect to one to put an entry in the right map, so either map answers.

Source

pub fn root(&self, schema: &str, table: &str, kind: &str) -> Option<&str>

The name given to one root field, if one was.

kind is Hasura’s own key – select, insert_one, delete_by_pk.

Source

pub fn column(&self, schema: &str, table: &str, column: &str) -> Option<&str>

The field a column is exposed as, if it was renamed.

Source

pub fn column_source( &self, schema: &str, table: &str, field: &str, ) -> Option<&str>

The column behind a field name, if that name is a rename.

The other direction, which is the one every resolver needs: it is handed a field name from the request and has to write a column. None means the name is already the column’s, which is the ordinary case.

Source

pub fn renames_columns(&self, schema: &str, table: &str) -> bool

Whether any column of this table is exposed under another name.

Worth asking before building a projection: a table with no renames keeps the SELECT * it had, and only one that has them pays for a column list.

Source

pub fn table_comment(&self, schema: &str, table: &str) -> Option<&str>

The description given to a table’s type, if one was.

Some("") is a description that was given and is empty, which means the type has none. None means nothing was said and the database’s own comment stands.

Source

pub fn column_comment( &self, schema: &str, table: &str, column: &str, ) -> Option<&str>

The description given to a column, by the column.

Source

pub fn computed_comment( &self, schema: &str, table: &str, function: &str, ) -> Option<&str>

The description given to a computed field, by its function.

Source

pub fn root_comment( &self, schema: &str, table: &str, kind: &str, ) -> Option<&str>

The description given to one root field, by its kind.

Source

pub fn computed_field( &self, schema: &str, table: &str, function: &str, ) -> Option<&str>

The name given to a computed field, by its function.

Reads both maps, for the reason Self::relationship gives.

Source

pub fn computed_source( &self, schema: &str, table: &str, field: &str, ) -> Option<&str>

The function behind a computed field, given the name it is exposed under.

The resolver reads the other direction: it is handed a field name from the selection and has to write the call. Searched rather than indexed because a table has a handful of computed fields, not thousands, and a second map would be one more thing to keep in step.

Trait Implementations§

Source§

impl Clone for NameOverrides

Source§

fn clone(&self) -> NameOverrides

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 NameOverrides

Source§

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

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

impl Default for NameOverrides

Source§

fn default() -> NameOverrides

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

impl PartialEq for NameOverrides

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NameOverrides

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> 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> 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, <T as TryFrom<U>>::Error>

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