query fetchMe {
    me {
        ...user
    }
}

query fetchUser($username: String!) {
    userByName(username: $username) {
        ...user
    }
}

fragment user on User {
    canonicalName
    email
    url
    location
    bio
}

query listSSHKeys($cursor: Cursor) {
    me {
        ...sshKeys
    }
}

query listSSHKeysByUser($username: String!, $cursor: Cursor) {
    userByName(username: $username) {
        ...sshKeys
    }
}

fragment sshKeys on User {
    sshKeys(cursor: $cursor) {
        results {
            id
            fingerprint
            comment
        }
        cursor
    }
}

query listRawSSHKeys($cursor: Cursor) {
    me {
        ...sshKeysRaw
    }
}

query listRawSSHKeysByUser($username: String!, $cursor: Cursor) {
    userByName(username: $username) {
        ...sshKeysRaw
    }
}

fragment sshKeysRaw on User {
    sshKeys(cursor: $cursor) {
        results {
            key
        }
        cursor
    }
}

query listPGPKeys($cursor: Cursor) {
    me {
        ...pgpKeys
    }
}

query listPGPKeysByUser($username: String!, $cursor: Cursor) {
    userByName(username: $username) {
        ...pgpKeys
    }
}

fragment pgpKeys on User {
    pgpKeys(cursor: $cursor) {
        results {
            id
            fingerprint
        }
        cursor
    }
}

query listRawPGPKeys($cursor: Cursor) {
    me {
        ...pgpKeysRaw
    }
}

query listRawPGPKeysByUser($username: String!, $cursor: Cursor) {
    userByName(username: $username) {
        ...pgpKeysRaw
    }
}

fragment pgpKeysRaw on User {
    pgpKeys(cursor: $cursor) {
        results {
            key
        }
        cursor
    }
}

query auditLog($cursor: Cursor) {
    auditLog(cursor: $cursor) {
        results {
            created
            ipAddress
            eventType
            details
        }
        cursor
    }
}

query userWebhooks($cursor: Cursor) {
    profileWebhooks(cursor: $cursor) {
        results {
            id
            url
        }
        cursor
    }
}

query personalAccessTokens {
    personalAccessTokens {
        issued
        expires
        comment
        grants
    }
}

query bio {
    me {
        bio
    }
}

mutation createSSHKey($key: String!) {
    createSSHKey(key: $key) {
        fingerprint
        comment
    }
}

mutation createPGPKey($key: String!) {
    createPGPKey(key: $key) {
        fingerprint
    }
}

mutation deleteSSHKey($id: Int!) {
    deleteSSHKey(id: $id) {
        fingerprint
    }
}

mutation deletePGPKey($id: Int!) {
    deletePGPKey(id: $id) {
        fingerprint
    }
}

mutation createUserWebhook($config: ProfileWebhookInput!) {
    createWebhook(config: $config) {
        id
    }
}

mutation deleteUserWebhook($id: Int!) {
    deleteWebhook(id: $id) {
        id
    }
}

mutation updateUser($input: UserInput) {
    updateUser(input: $input) {
        canonicalName
    }
}

mutation clearUserLocation {
    updateUser(input: { location: null }) {
        canonicalName
    }
}

mutation clearUserURL {
    updateUser(input: { url: null }) {
        canonicalName
    }
}

mutation clearBio {
    updateUser(input: { bio: null }) {
        canonicalName
    }
}
