pub struct Query;
Expand description
Query struct
Implementations§
Source§impl Query
impl Query
Sourceasync fn api_version(&self, _: &Context<'_>) -> Result<&'static str>
async fn api_version(&self, _: &Context<'_>) -> Result<&'static str>
Returns the API version. It is like a “greet” function
Sourceasync fn users<'ctx>(
&self,
ctx: &Context<'ctx>,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Option<Vec<User>>, AppError>
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 }}"}'
Sourceasync fn user<'ctx>(
&self,
ctx: &Context<'ctx>,
id: i32,
) -> Result<User, AppError>
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 }}"}'
Sourceasync fn positions<'ctx>(
&self,
ctx: &Context<'ctx>,
moving_activity: Option<Vec<MovingActivity>>,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Option<Vec<Position>>, AppError>
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}}"}'
Sourceasync fn alerts<'ctx>(
&self,
ctx: &Context<'ctx>,
id: Option<i32>,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Option<Vec<Alert>>, AppError>
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 }}"}'
Sourceasync 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>
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
impl ContainerType for Query
Source§async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
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 moreSource§async fn find_entity(
&self,
ctx: &Context<'_>,
params: &Value,
) -> ServerResult<Option<Value>>
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
Source§impl OutputType for Query
impl OutputType for Query
Source§fn create_type_info(registry: &mut Registry) -> String
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>
async fn resolve( &self, ctx: &ContextSelectionSet<'_>, _field: &Positioned<Field>, ) -> ServerResult<Value>
Resolve an output value to
async_graphql::Value
.§fn qualified_type_name() -> String
fn qualified_type_name() -> String
Qualified typename.
§fn introspection_type_name(&self) -> Cow<'static, str>
fn introspection_type_name(&self) -> Cow<'static, str>
Introspection type name Read more
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> 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
Mutably borrows from an owned value. Read more