fragment VideoMediaMetadataFields on VideoMediaMetadata {
  id
  pixelHeight
  pixelWidth
}

fragment LicenseFields on License {
  id
  code
  attribution
  customText
}

fragment VideoFields on Video {
  id
  title
  description
  category {
    id
  }
  views
  duration
  createdAt
  isPublic
  isExplicit
  isFeatured
  hasMarketing
  isCensored
  language {
    iso
  }
  publishedBeforeJoystream
  mediaMetadata {
    ...VideoMediaMetadataFields
  }
  mediaUrls
  mediaAvailability
  mediaDataObject {
    ...DataObjectFields
  }
  thumbnailPhotoUrls
  thumbnailPhotoAvailability
  thumbnailPhotoDataObject {
    ...DataObjectFields
  }
  channel {
    ...BasicChannelFields
  }
  license {
    ...LicenseFields
  }
}

query GetVideo($where: VideoWhereUniqueInput!) {
  videoByUniqueInput(where: $where) {
    ...VideoFields
  }
}

query GetVideosConnection(
  $first: Int
  $after: String
  $orderBy: VideoOrderByInput = createdAt_DESC
  $where: VideoWhereInput
) {
  videosConnection(first: $first, after: $after, where: $where, orderBy: $orderBy) {
    edges {
      cursor
      node {
        ...VideoFields
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}

query GetVideos($offset: Int, $limit: Int, $where: VideoWhereInput, $orderBy: VideoOrderByInput = createdAt_DESC) {
  videos(offset: $offset, limit: $limit, where: $where, orderBy: $orderBy) {
    ...VideoFields
  }
}

query GetCoverVideo {
  coverVideo {
    video {
      ...VideoFields
    }
    coverDescription
    coverCutMediaMetadata {
      ...VideoMediaMetadataFields
    }
  }
}

### Orion

# modyfying this query name will need a sync-up in `src/api/client/resolvers.ts`
query GetVideoViews($videoId: ID!) {
  videoViews(videoId: $videoId) {
    id
    views
  }
}

mutation AddVideoView($videoId: ID!, $channelId: ID!) {
  addVideoView(videoId: $videoId, channelId: $channelId) {
    id
    views
  }
}
