query repositoryIDByName($name: String!) {
    me {
        repository(name: $name) {
            id
        }
    }
}

query repositoryIDByUser($username: String!, $name: String!) {
    user(username: $username) {
        repository(name: $name) {
            id
        }
    }
}

query repositories($cursor: Cursor) {
    repositories(cursor: $cursor) {
        ...repos
    }
}

query repositoriesByUser($username: String!, $cursor: Cursor) {
    user(username: $username) {
        repositories(cursor: $cursor) {
            ...repos
        }
    }
}

fragment repos on RepositoryCursor {
    results {
        name
        description
        visibility
        owner {
            canonicalName
        }
    }
    cursor
}

query exportRepository($username: String!, $name: String!) {
    user(username: $username) {
        repository(name: $name) {
            ...repositoryExport
        }
    }
}

query exportRepositories($cursor: Cursor) {
    repositories(cursor: $cursor) {
        results {
            ...repositoryExport
        }
        cursor
    }
}

fragment repositoryExport on Repository {
    name
    owner {
        canonicalName
    }
    description
    visibility
    readme
    nonPublishing
}

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

query sshSettings {
    version {
        settings {
            sshUser
        }
    }
}

query completeRepositories {
    repositories {
        results {
            name
        }
    }
}

query aclByRepoName($name: String!, $cursor: Cursor) {
    me {
        ...acl
    }
}

query aclByUser($username: String!, $name: String!, $cursor: Cursor) {
    user(username: $username) {
        ...acl
    }
}

fragment acl on User {
    repository(name: $name) {
        accessControlList(cursor: $cursor) {
            results {
                id
                created
                entity {
                    canonicalName
                }
                mode
            }
            cursor
        }
    }
}

mutation createRepository(
    $name: String!
    $visibility: Visibility!
    $description: String!
) {
    createRepository(
        name: $name
        visibility: $visibility
        description: $description
    ) {
        id
        name
        owner {
            canonicalName
        }
    }
}

mutation updateRepository($id: Int!, $input: RepoInput!) {
    updateRepository(id: $id, input: $input) {
        name
    }
}

mutation clearCustomReadme($id: Int!) {
    updateRepository(id: $id, input: { readme: null }) {
        name
    }
}

mutation clearDescription($id: Int!) {
    updateRepository(id: $id, input: { description: null }) {
        name
    }
}

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

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

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

mutation updateACL($repoId: Int!, $mode: AccessMode!, $entity: ID!) {
    updateACL(repoId: $repoId, mode: $mode, entity: $entity) {
        entity {
            canonicalName
        }
    }
}

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