diff options
Diffstat (limited to 'src/graphql')
| -rw-r--r-- | src/graphql/mutation.rs | 53 | ||||
| -rw-r--r-- | src/graphql/query.rs | 32 | 
2 files changed, 85 insertions, 0 deletions
| diff --git a/src/graphql/mutation.rs b/src/graphql/mutation.rs index 1440ced..a389a04 100644 --- a/src/graphql/mutation.rs +++ b/src/graphql/mutation.rs @@ -15,6 +15,21 @@ pub struct Mutation;  #[Object]  impl Mutation {      /// Make GraphQL login +    /// +    /// Example: +    /// ```text +    /// curl -X POST http://localhost:8000/graphql \ +    /// -H "Content-Type: application/json" \ +    /// -d '{ +    ///   "query": "mutation Login($input: LoginCredentials!) { login(input: $input) { accessToken tokenType userId } }", +    ///   "variables": { +    ///     "input": { +    ///       "email": "***", +    ///       "password": "***" +    ///     } +    ///   } +    /// }' +    /// ```      async fn login<'ctx>(          &self,          ctx: &Context<'ctx>, @@ -44,6 +59,23 @@ impl Mutation {      }      /// Make GraphQL request to create new position to track +    /// +    /// Example: +    /// ```text +    /// curl -X POST http://localhost:8000/graphql \ +    /// -H "Content-Type: application/json" \ +    /// -H "Authorization: Bearer ***" \ +    /// -d '{ +    ///   "query": "mutation NewPosition($input: PositionInput!) { newPosition(input: $input) { id userId createdAt latitude longitude movingActivity } }", +    ///   "variables": { +    ///     "input": { +    ///       "latitude": 44.50800643571219, +    ///       "longitude": 11.299600981136905, +    ///       "movingActivity": "STILL" +    ///     } +    ///   } +    /// }' +    /// ```      async fn new_position<'ctx>(          &self,          ctx: &Context<'ctx>, @@ -94,6 +126,27 @@ impl Mutation {      }      /// Make GraphQL request to create new alert. Only for admins. +    /// +    /// Example: +    /// ```text +    /// curl -X POST http://localhost:8000/graphql \ +    /// -H "Content-Type: application/json" \ +    /// -H "Authorization: Bearer ****" \ +    /// -d '{ +    ///   "query": "mutation NewAlert($input: AlertInput!) { newAlert(input: $input) { id createdAt level } }", +    ///   "variables": { +    ///     "input": { +    ///       "points": [ +    ///         { "latitude": 44.490025, "longitude": 11.311499}, +    ///         { "latitude": 44.490361, "longitude": 11.327903}, +    ///         { "latitude": 44.497280, "longitude": 11.327776}, +    ///         { "latitude": 44.498321, "longitude": 11.312145}, +    ///         { "latitude": 44.490025, "longitude": 11.311498} +    ///       ], +    ///       "level": "TWO" +    ///     } +    ///   } +    /// }      async fn new_alert<'ctx>(          &self,          ctx: &Context<'ctx>, diff --git a/src/graphql/query.rs b/src/graphql/query.rs index 0bc5682..27ef11f 100644 --- a/src/graphql/query.rs +++ b/src/graphql/query.rs @@ -12,6 +12,14 @@ impl Query {      }      /// Returns all the users +    /// +    /// Request example: +    /// ```text +    /// curl http://localhost:8000/graphql +    /// -H 'authorization: Bearer ***' +    /// -H 'content-type: application/json' +    /// -d '{"query":"{users(limit: 2) { id, email, password, isAdmin }}"}' +    /// ```      async fn users<'ctx>(          &self,          ctx: &Context<'ctx>, @@ -22,6 +30,14 @@ impl Query {      }      /// Returns all the positions +    /// +    /// Request example: +    /// ```text +    /// curl http://localhost:8000/graphql +    /// -H 'authorization: Bearer ***' +    /// -H 'content-type: application/json' +    /// -d '{"query":"{positions {id, userId, createdAt, latitude, longitude, movingActivity}}"}' +    /// ```      async fn positions<'ctx>(          &self,          ctx: &Context<'ctx>, @@ -34,6 +50,14 @@ impl Query {      /// Returns all the last positions for each user.      /// It is restricted to only admin users. +    /// +    /// Request example: +    /// ```text +    /// curl http://localhost:8000/graphql +    /// -H 'authorization: Bearer ***' +    /// -H 'content-type: application/json' +    /// -d '{"query":"lastPositions(movingActivity: IN_VEHICLE) {id, userId, createdAt, latitude, longitude, movingActivity}}"}' +    /// ```      async fn last_positions<'ctx>(          &self,          ctx: &Context<'ctx>, @@ -45,6 +69,14 @@ impl Query {      }      /// Returns all the positions +    /// +    /// Request example: +    /// ```text +    /// curl http://localhost:8000/graphql +    /// -H 'authorization: Bearer ***' +    /// -H 'content-type: application/json' +    /// -d '{"query":"{alerts(id: 12) {id, userId, createdAt, area, extendedArea, level}}"}' +    /// ```      async fn alerts<'ctx>(          &self,          ctx: &Context<'ctx>, | 
