Skip to main content

SchemaConfig

Struct SchemaConfig 

Source
#[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
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.
§exposed_schemas: Vec<String>

Schemas to expose in GraphQL (e.g., [“public”])

§enable_mutations: bool

Whether to generate mutation types

§enable_subscriptions: bool

Whether to generate subscription types

§subscription_refresh_seconds: u64

How 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 at startup, and again whenever the schema is rebuilt, 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: NameOverrides

Names 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: bool

Whether 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

Source

pub fn new() -> Self

Create a new schema config.

Source

pub fn with_schemas(self, schemas: Vec<String>) -> Self

Set the exposed schemas.

Source

pub fn with_mutations(self, enable: bool) -> Self

Enable or disable mutations.

Source

pub fn with_subscriptions(self, enable: bool) -> Self

Enable or disable subscriptions.

Source

pub fn is_shared_entity(&self, table: &QualifiedIdentifier) -> bool

Whether a table keeps its unprefixed type identity across subgraphs.

Source

pub fn table_type_name( &self, table: &QualifiedIdentifier, base_name: &str, ) -> String

Name a table type, applying the configured namespace unless it is shared.

Source

pub fn root_field_name(&self, base_name: &str) -> String

Namespace a root field so independently generated subgraphs do not collide.

Source

pub fn subscription_refresh(&self) -> Duration

How often a live query re-reads itself when nothing has notified it.

Source

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

Check if a schema is exposed.

Source

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

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 SchemaConfig

Source§

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

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

impl Default for SchemaConfig

Source§

fn default() -> Self

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

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