Update docs

This commit is contained in:
Douglas Barone 2020-12-21 15:27:24 -04:00
parent e8261609ce
commit f69165dd77

View File

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