#[non_exhaustive]pub struct NameOverrides { /* private fields */ }Expand description
Every name given, keyed by schema.table.
Implementations§
Source§impl NameOverrides
impl NameOverrides
Sourcepub fn parse(value: &str) -> Result<Self, String>
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.
Sourcepub fn exposed_as(&self, schema: &str, function: &str) -> Option<&str>
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.
Sourcepub fn function_grants(&self, schema: &str, function: &str, role: &str) -> bool
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.
Sourcepub fn declared_relationships(
&self,
schema: &str,
table: &str,
) -> Option<&[DeclaredRelationship]>
pub fn declared_relationships( &self, schema: &str, table: &str, ) -> Option<&[DeclaredRelationship]>
The relationships metadata declares for a table, where it declares any.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many tables were named, for the line the server logs at startup.
Sourcepub fn placed_functions(&self) -> usize
pub fn placed_functions(&self) -> usize
How many functions were placed, for the same line.
Sourcepub fn permissions(
&self,
schema: &str,
table: &str,
role: &str,
) -> Option<&RolePermissions>
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.
Sourcepub fn tables_with_permissions<'a>(
&'a self,
role: &'a str,
) -> impl Iterator<Item = &'a RolePermissions> + 'a
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.
Sourcepub fn introspection_disabled(&self, role: &str) -> bool
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.
Sourcepub fn has_permissions(&self) -> bool
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.
Sourcepub fn roles(&self) -> Vec<&str>
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.
Sourcepub fn granted(&self) -> usize
pub fn granted(&self) -> usize
How many table-and-role pairs were granted something, for the line the server logs at startup.
Sourcepub fn is_enum(&self, schema: &str, table: &str) -> bool
pub fn is_enum(&self, schema: &str, table: &str) -> bool
Whether a table was marked as a set of allowed values.
Whether metadata marks this table as a shared Apollo Federation entity.
Sourcepub fn enum_tables(&self) -> Vec<(String, String)>
pub fn enum_tables(&self) -> Vec<(String, String)>
Every table marked as one, as (schema, table).
Sourcepub fn base_name(&self, schema: &str, table: &str) -> Option<&str>
pub fn base_name(&self, schema: &str, table: &str) -> Option<&str>
The base name given to a table, if one was.
Sourcepub fn relationship(
&self,
schema: &str,
table: &str,
source: &str,
) -> Option<&str>
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.
Sourcepub fn root(&self, schema: &str, table: &str, kind: &str) -> Option<&str>
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.
Sourcepub fn column(&self, schema: &str, table: &str, column: &str) -> Option<&str>
pub fn column(&self, schema: &str, table: &str, column: &str) -> Option<&str>
The field a column is exposed as, if it was renamed.
Sourcepub fn column_type(
&self,
schema: &str,
table: &str,
column: &str,
) -> Option<GraphQLType>
pub fn column_type( &self, schema: &str, table: &str, column: &str, ) -> Option<GraphQLType>
The GraphQL scalar a column is exposed as, if metadata overrides it.
Sourcepub fn column_source(
&self,
schema: &str,
table: &str,
field: &str,
) -> Option<&str>
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.
Sourcepub fn renames_columns(&self, schema: &str, table: &str) -> bool
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.
Sourcepub fn table_comment(&self, schema: &str, table: &str) -> Option<&str>
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.
Sourcepub fn column_comment(
&self,
schema: &str,
table: &str,
column: &str,
) -> Option<&str>
pub fn column_comment( &self, schema: &str, table: &str, column: &str, ) -> Option<&str>
The description given to a column, by the column.
Sourcepub fn computed_comment(
&self,
schema: &str,
table: &str,
function: &str,
) -> Option<&str>
pub fn computed_comment( &self, schema: &str, table: &str, function: &str, ) -> Option<&str>
The description given to a computed field, by its function.
Sourcepub fn root_comment(
&self,
schema: &str,
table: &str,
kind: &str,
) -> Option<&str>
pub fn root_comment( &self, schema: &str, table: &str, kind: &str, ) -> Option<&str>
The description given to one root field, by its kind.
Sourcepub fn computed_field(
&self,
schema: &str,
table: &str,
function: &str,
) -> Option<&str>
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.
Sourcepub fn computed_source(
&self,
schema: &str,
table: &str,
field: &str,
) -> Option<&str>
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
impl Clone for NameOverrides
Source§impl Debug for NameOverrides
impl Debug for NameOverrides
Source§impl Default for NameOverrides
impl Default for NameOverrides
Source§impl PartialEq for NameOverrides
impl PartialEq for NameOverrides
impl StructuralPartialEq for NameOverrides
Auto Trait Implementations§
impl Freeze for NameOverrides
impl RefUnwindSafe for NameOverrides
impl Send for NameOverrides
impl Sync for NameOverrides
impl Unpin for NameOverrides
impl UnsafeUnpin for NameOverrides
impl UnwindSafe for NameOverrides
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