type KeycloakUser {
    keycloakId: String
    username: String
}

type UserResult {
    totalCount: Int
    count: Int
    nodes: [User]
}

type UserHistory implements DbHistoryModel {
    id: Int
    keycloakId: String
    username: String
    email: String

    roles: [Role]

    deleted: Boolean
    editor: String
    created: String
    updated: String
}

type User implements DbModel {
    id: Int
    keycloakId: String
    username: String
    email: String
    roles: [Role]

    deleted: Boolean
    editor: User
    created: String
    updated: String

    history: [UserHistory]
}

input UserSort {
    id: SortOrder
    keycloakId: SortOrder
    username: SortOrder
    email: SortOrder

    deleted: SortOrder
    editor: UserSort
    created: SortOrder
    updated: SortOrder
}

enum UserFuzzyFields {
    id
    keycloakId
    username
    email

    deleted
    editor
    created
    updated
}

input UserFuzzy {
    fields: [UserFuzzyFields]
    term: String
    threshold: Int
}

input UserFilter {
    id: IntFilter
    keycloakId: StringFilter
    username: StringFilter
    email: StringFilter

    fuzzy: UserFuzzy

    deleted: BooleanFilter
    editor: UserFilter
    created: DateFilter
    updated: DateFilter
}

type UserMutation {
    create(input: UserCreateInput!): User
    update(input: UserUpdateInput!): User
    delete(id: Int!): Boolean
    restore(id: Int!): Boolean
}

input UserCreateInput {
    keycloakId: String
    roles: [Int]
}

input UserUpdateInput {
    id: Int
    roles: [Int]
}