mutation deleteMailingList($id: Int!) {
    deleteMailingList(id: $id) {
        name
    }
}

query mailingLists($cursor: Cursor) {
    me {
        lists(cursor: $cursor) {
            ...lists
        }
    }
}

query exportMailingLists {
    me {
        lists {
            results {
                name
                description
                permitMime
                rejectMime
                archive
            }
        }
    }
}

query mailingListsByUser($username: String!, $cursor: Cursor) {
    user(username: $username) {
        lists(cursor: $cursor) {
            ...lists
        }
    }
}

fragment lists on MailingListCursor {
    results {
        name
        description
        visibility
    }
    cursor
}

query mailingListIDByName($name: String!) {
    me {
        list(name: $name) {
            id
        }
    }
}

query mailingListIDByUser($username: String!, $name: String!) {
    user(username: $username) {
        list(name: $name) {
            id
        }
    }
}

query listPatches($name: String!) {
    me {
        list(name: $name) {
            ...patchsetsByList
        }
    }
}

query listPatchesByUser($username: String!, $name: String!) {
    user(username: $username) {
        list(name: $name) {
            ...patchsetsByList
        }
    }
}

fragment patchsetsByList on MailingList {
    patches {
        results {
            id
            subject
            status
            created
            version
            prefix
            submitter {
                canonicalName
            }
        }
    }
}

query patches {
    me {
        ...patchsets
    }
}

query patchesByUser($username: String!) {
    user(username: $username) {
        ...patchsets
    }
}

fragment patchsets on User {
    patches {
        results {
            id
            subject
            status
            created
            version
            prefix
            list {
                name
                owner {
                    canonicalName
                }
            }
        }
    }
}

query patchsetById($id: Int!) {
    patchset(id: $id) {
        patches {
            results {
                date
                body
                subject
                header(want: "From")
            }
        }
    }
}

query completePatchsetId($name: String!) {
    me {
        list(name: $name) {
            ...completePatchset
        }
    }
}

query completePatchsetIdByUser($username: String!, $name: String!) {
    user(username: $username) {
        list(name: $name) {
            ...completePatchset
        }
    }
}

fragment completePatchset on MailingList {
    patches {
        results {
            id
            subject
            status
            version
            prefix
        }
    }
}

query aclByListName($name: String!) {
    me {
        list(name: $name) {
            defaultACL {
                browse
                reply
                post
                moderate
            }
            acl {
                results {
                    id
                    created
                    entity {
                        canonicalName
                    }
                    browse
                    reply
                    post
                    moderate
                }
            }
        }
    }
}

query userWebhooks {
    userWebhooks {
        results {
            id
            url
        }
    }
}

query archive($name: String!) {
    me {
        list(name: $name) {
            archive
        }
    }
}

query archiveByUser($username: String!, $name: String!) {
    user(username: $username) {
        list(name: $name) {
            archive
        }
    }
}

query completeLists {
    me {
        lists {
            results {
                name
            }
        }
    }
}

query mailingListWebhooks($name: String!) {
    me {
        list(name: $name) {
            ...mailingListWebhooks
        }
    }
}

query mailingListWebhooksByUser($username: String!, $name: String!) {
    user(username: $username) {
        list(name: $name) {
            ...mailingListWebhooks
        }
    }
}

fragment mailingListWebhooks on MailingList {
    webhooks {
        results {
            id
            url
        }
    }
}

mutation mailingListSubscribe($listID: Int!) {
    mailingListSubscribe(listID: $listID) {
        list {
            name
            owner {
                canonicalName
            }
        }
    }
}

mutation mailingListUnsubscribe($listID: Int!) {
    mailingListUnsubscribe(listID: $listID) {
        list {
            name
            owner {
                canonicalName
            }
        }
    }
}

mutation updatePatchset($id: Int!, $status: PatchsetStatus!) {
    updatePatchset(id: $id, status: $status) {
        submitter {
            canonicalName
        }
        subject
    }
}

mutation deleteACL($id: Int!) {
    deleteACL(id: $id) {
        entity {
            canonicalName
        }
        list {
            name
        }
    }
}

mutation createMailingList(
    $name: String!
    $description: String
    $visibility: Visibility!
) {
    createMailingList(
        name: $name
        description: $description
        visibility: $visibility
    ) {
        name
    }
}

mutation createUserWebhook($config: UserWebhookInput!) {
    createUserWebhook(config: $config) {
        id
    }
}

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

mutation createMailingListWebhook(
    $listId: Int!
    $config: MailingListWebhookInput!
) {
    createMailingListWebhook(listId: $listId, config: $config) {
        id
    }
}

mutation deleteMailingListWebhook($id: Int!) {
    deleteMailingListWebhook(id: $id) {
        id
    }
}
