cas::graphql::query

Struct Query

Source
pub struct Query;
Expand description

Query struct

Implementations§

Source§

impl Query

Source

async fn api_version(&self, _: &Context<'_>) -> Result<&'static str>

Returns the API version. It is like a “greet” function

Source

async fn users<'ctx>( &self, ctx: &Context<'ctx>, limit: Option<i64>, offset: Option<i64>, ) -> Result<Option<Vec<User>>, AppError>

Returns all the users. It is restricted to admins only.

Request example:

curl http://localhost:8000/graphql
-H 'authorization: Bearer ***'
-H 'content-type: application/json'
-d '{"query":"{users(limit: 2) { id, email, password, name, address, isAdmin }}"}'
Source

async fn user<'ctx>( &self, ctx: &Context<'ctx>, id: i32, ) -> Result<User, AppError>

Returns an user by ID. Admins can check everyone.

Request example:

curl http://localhost:8000/graphql
-H 'authorization: Bearer ***'
-H 'content-type: application/json'
-d '{"query":"{user(id: 1) { id, email, password, name, address, isAdmin }}"}'
Source

async fn positions<'ctx>( &self, ctx: &Context<'ctx>, moving_activity: Option<Vec<MovingActivity>>, limit: Option<i64>, offset: Option<i64>, ) -> Result<Option<Vec<Position>>, AppError>

Returns all the positions. It is restricted to admins only.

Request example:

curl http://localhost:8000/graphql
-H 'authorization: Bearer ***'
-H 'content-type: application/json'
-d '{"query":"{positions(movingActivity: IN_VEHICLE) {id, userId, createdAt, latitude, longitude, movingActivity}}"}'
Source

async fn alerts<'ctx>( &self, ctx: &Context<'ctx>, id: Option<i32>, limit: Option<i64>, offset: Option<i64>, ) -> Result<Option<Vec<Alert>>, AppError>

Returns all the positions

Request example:

curl http://localhost:8000/graphql
-H 'authorization: Bearer ***'
-H 'content-type: application/json'
-d '{"query":"{alerts(id: 12) {id, userId, createdAt, area, areaLevel2, areaLevel3, text1, text2, text3, notifications {userId, latitude, longitude }}"}'
Source

async fn notifications<'ctx>( &self, ctx: &Context<'ctx>, seen: Option<bool>, id: Option<i32>, alert_id: Option<i32>, limit: Option<i64>, offset: Option<i64>, ) -> Result<Option<Vec<Notification>>, AppError>

Returns all the notifications. They can be filtered by an alert id.

Request example:

curl http://localhost:8000/graphql
-H 'authorization: Bearer ***'
-H 'content-type: application/json'
-d '{"query":"{notifications {
id,
alert { id, userId, createdAt, area, areaLevel2, areaLevel3, text1, text2, text3, audio1, audio2, audio3, reachedUsers },
userId, latitude, longitude, movingActivity, level, seen, createdAt
}}"}'

Trait Implementations§

Source§

impl ContainerType for Query

Source§

async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>

Resolves a field value and outputs it as a json value async_graphql::Value. Read more
Source§

async fn find_entity( &self, ctx: &Context<'_>, params: &Value, ) -> ServerResult<Option<Value>>

Find the GraphQL entity with the given name from the parameter. Read more
§

fn collect_all_fields<'a>( &'a self, ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>, fields: &mut Fields<'a>, ) -> Result<(), ServerError>
where Self: Send + Sync,

Collect all the fields of the container that are queried in the selection set. Read more
Source§

impl OutputType for Query

Source§

fn type_name() -> Cow<'static, str>

Type the name.
Source§

fn create_type_info(registry: &mut Registry) -> String

Create type information in the registry and return qualified typename.
Source§

async fn resolve( &self, ctx: &ContextSelectionSet<'_>, _field: &Positioned<Field>, ) -> ServerResult<Value>

Resolve an output value to async_graphql::Value.
§

fn qualified_type_name() -> String

Qualified typename.
§

fn introspection_type_name(&self) -> Cow<'static, str>

Introspection type name Read more
Source§

impl ObjectType for Query

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnwindSafe for Query

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more