fragment BasicChannelFields on Channel {
  id
  title
  createdAt

  avatarPhotoUrls
  avatarPhotoAvailability
  avatarPhotoDataObject {
    ...DataObjectFields
  }
}

fragment AllChannelFields on Channel {
  ...BasicChannelFields
  description
  follows
  isPublic
  isCensored
  language {
    iso
  }

  coverPhotoUrls
  coverPhotoAvailability
  coverPhotoDataObject {
    ...DataObjectFields
  }
}

query GetBasicChannel($where: ChannelWhereUniqueInput!) {
  channelByUniqueInput(where: $where) {
    ...BasicChannelFields
  }
}

query GetChannel($where: ChannelWhereUniqueInput!) {
  channelByUniqueInput(where: $where) {
    ...AllChannelFields
  }
}

query GetVideoCount($where: VideoWhereInput) {
  videosConnection(first: 0, where: $where) {
    totalCount
  }
}

query GetChannels($where: ChannelWhereInput) {
  channels(where: $where) {
    ...AllChannelFields
  }
}

query GetChannelsConnection($first: Int, $after: String, $where: ChannelWhereInput) {
  channelsConnection(first: $first, after: $after, where: $where, orderBy: createdAt_DESC) {
    edges {
      cursor
      node {
        ...AllChannelFields
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}

### Orion

# modyfying this query name will need a sync-up in `src/api/client/resolvers.ts`
query GetChannelFollows($channelId: ID!) {
  channelFollows(channelId: $channelId) {
    id
    follows
  }
}

mutation FollowChannel($channelId: ID!) {
  followChannel(channelId: $channelId) {
    id
    follows
  }
}

mutation UnfollowChannel($channelId: ID!) {
  unfollowChannel(channelId: $channelId) {
    id
    follows
  }
}
