#[non_exhaustive]pub struct SchemaConfig {
pub exposed_schemas: Vec<String>,
pub enable_mutations: bool,
pub enable_subscriptions: bool,
pub subscription_refresh_seconds: u64,
pub enum_values: HashMap<String, Vec<(String, Option<String>)>>,
pub names: NameOverrides,
pub max_rows: Option<i64>,
pub enable_federation: bool,
pub type_prefix: Option<String>,
pub role: Option<String>,
}Expand description
Configuration for schema generation.
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.exposed_schemas: Vec<String>Schemas to expose in GraphQL (e.g., [“public”])
enable_mutations: boolWhether to generate mutation types
enable_subscriptions: boolWhether to generate subscription types
subscription_refresh_seconds: u64How often a live query re-reads itself when nothing has notified it.
A subscription is woken by the trigger on the table it reads, which costs nothing while nothing is written. A trigger cannot see everything: a view has none, an embedded row may live in a table that carries none, and a predicate written against the clock changes with no write at all. This is how often those are noticed anyway. Seconds; zero turns the refresh off and leaves only the notifications.
enum_values: HashMap<String, Vec<(String, Option<String>)>>The members of each enum table, keyed by schema.table, as
(value, comment).
These are rows rather than schema, so they cannot come from the schema cache: they are read once at startup, for the tables the configuration marks. A table marked as an enum whose values are absent is exposed as an ordinary table – an empty GraphQL enum is not a legal type, and refusing to start over a table with no rows in it would be worse.
names: NameOverridesNames given rather than derived.
Empty by default, which is every name derived from the schema exactly as before.
max_rows: Option<i64>Ceiling on rows a single query may return (PGRST_MAX_ROWS).
Applied when a query supplies no limit of its own, and as an upper
bound when it supplies a larger one. None leaves queries unbounded.
enable_federation: boolWhether this schema is emitted as an Apollo Federation subgraph.
type_prefix: Option<String>Namespace applied to generated table types and root fields.
role: Option<String>Whose schema this is.
None is the unrestricted one: what an administrator sees, and what
every caller sees on a server with no permission document. Some(role)
is built from a cache already reduced to what that role may see, so the
only thing left for the builders to ask about is the aggregate root.
Implementations§
Source§impl SchemaConfig
impl SchemaConfig
Sourcepub fn with_schemas(self, schemas: Vec<String>) -> Self
pub fn with_schemas(self, schemas: Vec<String>) -> Self
Set the exposed schemas.
Sourcepub fn with_mutations(self, enable: bool) -> Self
pub fn with_mutations(self, enable: bool) -> Self
Enable or disable mutations.
Sourcepub fn with_subscriptions(self, enable: bool) -> Self
pub fn with_subscriptions(self, enable: bool) -> Self
Enable or disable subscriptions.
Whether a table keeps its unprefixed type identity across subgraphs.
Sourcepub fn table_type_name(
&self,
table: &QualifiedIdentifier,
base_name: &str,
) -> String
pub fn table_type_name( &self, table: &QualifiedIdentifier, base_name: &str, ) -> String
Name a table type, applying the configured namespace unless it is shared.
Sourcepub fn root_field_name(&self, base_name: &str) -> String
pub fn root_field_name(&self, base_name: &str) -> String
Namespace a root field so independently generated subgraphs do not collide.
Sourcepub fn subscription_refresh(&self) -> Duration
pub fn subscription_refresh(&self) -> Duration
How often a live query re-reads itself when nothing has notified it.
Sourcepub fn is_schema_exposed(&self, schema: &str) -> bool
pub fn is_schema_exposed(&self, schema: &str) -> bool
Check if a schema is exposed.
Sourcepub fn default_schema(&self) -> &str
pub fn default_schema(&self) -> &str
The schema whose tables get unqualified GraphQL names.
This is the first exposed schema, mirroring how the REST surface treats
the first entry of PGRST_DB_SCHEMAS as the default.
Trait Implementations§
Source§impl Clone for SchemaConfig
impl Clone for SchemaConfig
Source§impl Debug for SchemaConfig
impl Debug for SchemaConfig
Auto Trait Implementations§
impl Freeze for SchemaConfig
impl RefUnwindSafe for SchemaConfig
impl Send for SchemaConfig
impl Sync for SchemaConfig
impl Unpin for SchemaConfig
impl UnsafeUnpin for SchemaConfig
impl UnwindSafe for SchemaConfig
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