From f69165dd77d77675e9259f3d397a35303367835d Mon Sep 17 00:00:00 2001 From: Douglas Barone Date: Mon, 21 Dec 2020 15:27:24 -0400 Subject: [PATCH] Update docs --- server/src/typeDefs.js | 47 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/server/src/typeDefs.js b/server/src/typeDefs.js index ee59ee6..638603c 100644 --- a/server/src/typeDefs.js +++ b/server/src/typeDefs.js @@ -2,28 +2,38 @@ import { gql } from 'apollo-server' const typeDefs = gql` type Query { - "Returns only a few fields of User" + "Returns only a few fields of a user" basicUser(sAMAccountName: String!): User! @cacheControl(maxAge: 350) + "The authenticated user" me: User! @auth @cacheControl(maxAge: 30, scope: PRIVATE) + + "All users matching the criteria" users( where: UserWhereInput! + "How many?" limit: Int = 15 + "Should return only students?" onlyStudents: Boolean = false ): [User!] @auth(roles: ["servant"]) @cacheControl(maxAge: 350) + "A single user" user(sAMAccountName: String!): User! @auth(roles: ["superAdmin"]) @cacheControl(maxAge: 350) + "AD groups" groups(where: GroupWhereInput!, limit: Int = 10): [Group!]! @auth(roles: ["servant"]) @cacheControl(maxAge: 350) + "Current stats. Differs from the historical statistics." stats: Stats! @cacheControl(maxAge: 30) + "Users who has some device currently connected to Wi-Fi" userPresence(search: String = ""): [UserPresence!] @auth(roles: ["watcher"]) + "Devices that uses the Wi-Fi" wifiDevices( search: String = "" identifiedOnly: Boolean = false @@ -32,41 +42,60 @@ const typeDefs = gql` @cacheControl(maxAge: 10, scope: PRIVATE) @auth(roles: ["superAdmin"]) + "Users that uses the Wi-Fi" wifiUsers: [User]! @auth(roles: ["superAdmin"]) @cacheControl(maxAge: 10, scope: PRIVATE) + "Application Logs" logs: [Log]! @auth(roles: ["superAdmin"]) @cacheControl(maxAge: 5, scope: PRIVATE) } type Mutation { + "System login" login(data: LoginInput!): AuthPayload! + + "Update own password" updatePassword(data: UpdatePasswordInput!): AuthPayload! @auth + + "Update someone elses password" replacePassword(data: ReplacePasswordInput!): String! @auth(roles: ["superAdmin"]) + + "Create a Reset Token to reset a student password" createResetToken(data: CreateResetTokenInput!): ResetToken! @auth(roles: ["superAdmin", "tokenCreator"]) + + "Use a provided Reset Token to update a user password" useResetToken(data: UseResetTokenInput!): Boolean! + + "Import all users from Active Directory" importUsers: String! @auth(roles: ["superAdmin"]) + + "Force update devices connected to Wi-Fi" updateWifiDevices: String! @auth(roles: ["superAdmin"]) + + "Force update user-id mapping on firewall" updateUserIdMappings: String! @auth(roles: ["superAdmin"]) } type Subscription { + "The information about users who has some device currently connected to Wi-Fi was updated" userPresenceUpdated: Int! @auth(roles: ["watcher"]) + + "Info about the logged user was updated" authUpdated: User! @auth } + "Needs authentication. Optionally, provide an array with roles to match." directive @auth(roles: [String!]) on FIELD_DEFINITION "A mix between the database User and the Active Directory User" type User { id: ID - wifiDevices: [WifiDevice!] - lastLogin: String lastLoginPrior: String roles: [String!] @@ -124,6 +153,7 @@ const typeDefs = gql` whenCreated: String } + "Active Directory Groups" type Group { cn: String! dn: String! @@ -131,12 +161,17 @@ const typeDefs = gql` members: [User!]! } + "Authentication payload" type AuthPayload { + "The user who has logged in" user: User! + "A Json Web Token used to authenticate with the API" token: String! + "Time to invalidate the provided token" expiresIn: String! } + "A token to be used for passwords updates" type ResetToken { id: ID! user: User! @@ -148,6 +183,7 @@ const typeDefs = gql` updatedAt: String! } + "Current stats" type Stats { tokenCountTotal: Int! tokenCountUsed: Int! @@ -160,6 +196,7 @@ const typeDefs = gql` onlineWifiDevices: Int! } + "A device connected to the Wi-Fi" type WifiDevice { user: User id: ID! @@ -176,6 +213,7 @@ const typeDefs = gql` status: Status } + "A user that is on the Wi-Fi network reach" type UserPresence { id: ID! displayName: String! @@ -185,12 +223,14 @@ const typeDefs = gql` apName: String! } + "The status of a Device" enum Status { ONLINE RECENT OFFLINE } + "A log message" type Log { id: ID! timestamp: String! @@ -200,6 +240,7 @@ const typeDefs = gql` data: String } + "The severity of a log entry" enum LogLevel { LOW INFO