juniper

Struct RootNode

Source
pub struct RootNode<'a, QueryT: GraphQLType<S>, MutationT: GraphQLType<S>, SubscriptionT: GraphQLType<S>, S = DefaultScalarValue>
where S: ScalarValue,
{ /* private fields */ }
Expand description

Root query node of a schema

This brings the mutation, subscription and query types together, and provides the predefined metadata fields.

Implementations§

Source§

impl<'a, QueryT, MutationT, SubscriptionT> RootNode<'a, QueryT, MutationT, SubscriptionT, DefaultScalarValue>
where QueryT: GraphQLType<DefaultScalarValue, TypeInfo = ()>, MutationT: GraphQLType<DefaultScalarValue, TypeInfo = ()>, SubscriptionT: GraphQLType<DefaultScalarValue, TypeInfo = ()>,

Source

pub fn new( query: QueryT, mutation: MutationT, subscription: SubscriptionT, ) -> Self

Constructs a new RootNode from query, mutation and subscription nodes, parametrizing it with a DefaultScalarValue.

Source§

impl<'a, QueryT, MutationT, SubscriptionT, S> RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where S: ScalarValue + 'a, QueryT: GraphQLType<S, TypeInfo = ()>, MutationT: GraphQLType<S, TypeInfo = ()>, SubscriptionT: GraphQLType<S, TypeInfo = ()>,

Source

pub fn new_with_scalar_value( query: QueryT, mutation: MutationT, subscription: SubscriptionT, ) -> Self

Constructs a new RootNode from query, mutation and subscription nodes, parametrizing it with the provided ScalarValue.

Source§

impl<'a, S, QueryT, MutationT, SubscriptionT> RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: GraphQLType<S>, MutationT: GraphQLType<S>, SubscriptionT: GraphQLType<S>, S: ScalarValue + 'a,

Source

pub fn new_with_info( query_obj: QueryT, mutation_obj: MutationT, subscription_obj: SubscriptionT, query_info: QueryT::TypeInfo, mutation_info: MutationT::TypeInfo, subscription_info: SubscriptionT::TypeInfo, ) -> Self

Construct a new root node from query and mutation nodes, while also providing type info objects for the query and mutation types.

Source

pub fn disable_introspection(self) -> Self

Disables introspection for this RootNode, making it to return a [FieldError] whenever its __schema or __type field is resolved.

By default, all introspection queries are allowed.

§Example
pub struct Query;

#[graphql_object]
impl Query {
    fn some() -> bool {
        true
    }
}

type Schema = RootNode<'static, Query, EmptyMutation, EmptySubscription>;

let schema = Schema::new(Query, EmptyMutation::new(), EmptySubscription::new())
    .disable_introspection();

let query = "query { __schema { queryType { name } } }";

match juniper::execute_sync(query, None, &schema, &graphql_vars! {}, &()) {
    Err(GraphQLError::ValidationError(errs)) => {
        assert_eq!(
            errs.first().unwrap().message(),
            "GraphQL introspection is not allowed, but the operation contained `__schema`",
        );
    }
    res => panic!("expected `ValidationError`, returned: {res:#?}"),
}
Source

pub fn enable_introspection(self) -> Self

Enables introspection for this RootNode, if it was previously disabled.

By default, all introspection queries are allowed.

Trait Implementations§

Source§

impl<'a, QueryT: Debug + GraphQLType<S>, MutationT: Debug + GraphQLType<S>, SubscriptionT: Debug + GraphQLType<S>, S> Debug for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where S: ScalarValue + Debug, QueryT::TypeInfo: Debug, MutationT::TypeInfo: Debug, SubscriptionT::TypeInfo: Debug,

Source§

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

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

impl<'a, S, QueryT, MutationT, SubscriptionT> GraphQLType<S> for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where S: ScalarValue, QueryT: GraphQLType<S>, MutationT: GraphQLType<S, Context = QueryT::Context>, SubscriptionT: GraphQLType<S, Context = QueryT::Context>,

Source§

fn name(info: &Self::TypeInfo) -> Option<&str>

Returns name of this GraphQLType to expose. Read more
Source§

fn meta<'r>( info: &Self::TypeInfo, registry: &mut Registry<'r, S>, ) -> MetaType<'r, S>
where S: 'r,

Returns MetaType representing this GraphQLType.
Source§

impl<'a, S, QueryT, MutationT, SubscriptionT> GraphQLValue<S> for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where S: ScalarValue, QueryT: GraphQLType<S>, MutationT: GraphQLType<S, Context = QueryT::Context>, SubscriptionT: GraphQLType<S, Context = QueryT::Context>,

Source§

type Context = <QueryT as GraphQLValue<S>>::Context

Context type for this GraphQLValue. Read more
Source§

type TypeInfo = <QueryT as GraphQLValue<S>>::TypeInfo

Type that may carry additional schema information for this GraphQLValue. Read more
Source§

fn type_name<'i>(&self, info: &'i Self::TypeInfo) -> Option<&'i str>

Returns name of the GraphQLType exposed by this GraphQLValue. Read more
Source§

fn concrete_type_name( &self, context: &Self::Context, info: &Self::TypeInfo, ) -> String

Returns the concrete GraphQLType name for this GraphQLValue being an interface, an union or an object. Read more
Source§

fn resolve_field( &self, info: &Self::TypeInfo, field: &str, args: &Arguments<'_, S>, executor: &Executor<'_, '_, Self::Context, S>, ) -> ExecutionResult<S>

Resolves the value of a single field on this GraphQLValue. Read more
Source§

fn resolve( &self, info: &Self::TypeInfo, selection_set: Option<&[Selection<'_, S>]>, executor: &Executor<'_, '_, Self::Context, S>, ) -> ExecutionResult<S>

Resolves the provided selection_set against this GraphQLValue. Read more
Source§

fn resolve_into_type( &self, info: &Self::TypeInfo, type_name: &str, selection_set: Option<&[Selection<'_, S>]>, executor: &Executor<'_, '_, Self::Context, S>, ) -> ExecutionResult<S>

Resolves this GraphQLValue (being an interface or an union) into a concrete downstream object type. Read more
Source§

impl<'a, S, QueryT, MutationT, SubscriptionT> GraphQLValueAsync<S> for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: GraphQLTypeAsync<S>, QueryT::TypeInfo: Sync, QueryT::Context: Sync + 'a, MutationT: GraphQLTypeAsync<S, Context = QueryT::Context>, MutationT::TypeInfo: Sync, SubscriptionT: GraphQLType<S, Context = QueryT::Context> + Sync, SubscriptionT::TypeInfo: Sync, S: ScalarValue + Send + Sync,

Source§

fn resolve_field_async<'b>( &'b self, info: &'b Self::TypeInfo, field_name: &'b str, arguments: &'b Arguments<'_, S>, executor: &'b Executor<'_, '_, Self::Context, S>, ) -> BoxFuture<'b, ExecutionResult<S>>

Resolves the value of a single field on this GraphQLValueAsync. Read more
Source§

fn resolve_into_type_async<'a>( &'a self, info: &'a Self::TypeInfo, type_name: &str, selection_set: Option<&'a [Selection<'a, S>]>, executor: &'a Executor<'a, 'a, Self::Context, S>, ) -> BoxFuture<'a, ExecutionResult<S>>

Resolves this GraphQLValueAsync (being an interface or an union) into a concrete downstream object type. Read more
Source§

fn resolve_async<'a>( &'a self, info: &'a Self::TypeInfo, selection_set: Option<&'a [Selection<'_, S>]>, executor: &'a Executor<'_, '_, Self::Context, S>, ) -> BoxFuture<'a, ExecutionResult<S>>

Resolves the provided selection_set against this GraphQLValueAsync. Read more

Auto Trait Implementations§

§

impl<'a, QueryT, MutationT, SubscriptionT, S> Freeze for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: Freeze, <QueryT as GraphQLValue<S>>::TypeInfo: Freeze, MutationT: Freeze, <MutationT as GraphQLValue<S>>::TypeInfo: Freeze, SubscriptionT: Freeze, <SubscriptionT as GraphQLValue<S>>::TypeInfo: Freeze,

§

impl<'a, QueryT, MutationT, SubscriptionT, S> RefUnwindSafe for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: RefUnwindSafe, <QueryT as GraphQLValue<S>>::TypeInfo: RefUnwindSafe, MutationT: RefUnwindSafe, <MutationT as GraphQLValue<S>>::TypeInfo: RefUnwindSafe, SubscriptionT: RefUnwindSafe, <SubscriptionT as GraphQLValue<S>>::TypeInfo: RefUnwindSafe, S: RefUnwindSafe,

§

impl<'a, QueryT, MutationT, SubscriptionT, S> Send for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: Send, <QueryT as GraphQLValue<S>>::TypeInfo: Send, MutationT: Send, <MutationT as GraphQLValue<S>>::TypeInfo: Send, SubscriptionT: Send, <SubscriptionT as GraphQLValue<S>>::TypeInfo: Send, S: Send,

§

impl<'a, QueryT, MutationT, SubscriptionT, S> Sync for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: Sync, <QueryT as GraphQLValue<S>>::TypeInfo: Sync, MutationT: Sync, <MutationT as GraphQLValue<S>>::TypeInfo: Sync, SubscriptionT: Sync, <SubscriptionT as GraphQLValue<S>>::TypeInfo: Sync, S: Sync,

§

impl<'a, QueryT, MutationT, SubscriptionT, S> Unpin for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: Unpin, <QueryT as GraphQLValue<S>>::TypeInfo: Unpin, MutationT: Unpin, <MutationT as GraphQLValue<S>>::TypeInfo: Unpin, SubscriptionT: Unpin, <SubscriptionT as GraphQLValue<S>>::TypeInfo: Unpin, S: Unpin,

§

impl<'a, QueryT, MutationT, SubscriptionT, S> UnwindSafe for RootNode<'a, QueryT, MutationT, SubscriptionT, S>
where QueryT: UnwindSafe, <QueryT as GraphQLValue<S>>::TypeInfo: UnwindSafe, MutationT: UnwindSafe, <MutationT as GraphQLValue<S>>::TypeInfo: UnwindSafe, SubscriptionT: UnwindSafe, <SubscriptionT as GraphQLValue<S>>::TypeInfo: UnwindSafe, S: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.