views.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { gql } from 'apollo-server-express'
  2. import { EntityViewsInfo } from '../../src/entities/EntityViewsInfo'
  3. import { ChannelConnection, VideoConnection } from '../../src/types'
  4. export const GET_MOST_VIEWED_VIDEOS_CONNECTION = gql`
  5. query GetMostViewedVideosConnection($periodDays: Int, $limit: Int!) {
  6. mostViewedVideosConnection(periodDays: $periodDays, limit: $limit) {
  7. edges {
  8. node {
  9. id
  10. views
  11. }
  12. }
  13. }
  14. }
  15. `
  16. export type GetMostViewedVideosConnection = {
  17. mostViewedVideosConnection: VideoConnection
  18. }
  19. export type GetMostViewedVideosConnectionArgs = {
  20. periodDays: number | null
  21. limit: number
  22. }
  23. export const GET_MOST_VIEWED_CHANNELS_CONNECTION = gql`
  24. query GetMostViewedChannelsConnection($periodDays: Int, $limit: Int!) {
  25. mostViewedChannelsConnection(periodDays: $periodDays, limit: $limit) {
  26. edges {
  27. node {
  28. id
  29. views
  30. }
  31. }
  32. }
  33. }
  34. `
  35. export type GetMostViewedChannelsConnection = {
  36. mostViewedChannelsConnection: ChannelConnection
  37. }
  38. export type GetMostViewedChannelsConnectionArgs = {
  39. periodDays: number | null
  40. limit: number
  41. }
  42. export const GET_MOST_VIEWED_CATEGORIES = gql`
  43. query GetMostViewedCategories($timePeriodDays: Int!) {
  44. mostViewedCategories(timePeriodDays: $timePeriodDays) {
  45. id
  46. views
  47. }
  48. }
  49. `
  50. export const GET_MOST_VIEWED_CATEGORIES_ALL_TIME = gql`
  51. query GetMostViewedVideosAllTime($limit: Int!) {
  52. mostViewedCategoriesAllTime(limit: $limit) {
  53. id
  54. views
  55. }
  56. }
  57. `
  58. export type GetMostViewedCategories = {
  59. mostViewedCategories: EntityViewsInfo[]
  60. }
  61. export type GetMostViewedCategoriesArgs = {
  62. timePeriodDays: number
  63. }
  64. export type GetMostViewedCategoriesAllTimeArgs = {
  65. limit: number
  66. }
  67. export type GetMostViewedCategoriesAllTime = {
  68. mostViewedCategoriesAllTime: EntityViewsInfo[]
  69. }
  70. export const ADD_VIDEO_VIEW = gql`
  71. mutation AddVideoView($videoId: ID!, $channelId: ID!, $categoryId: ID) {
  72. addVideoView(videoId: $videoId, channelId: $channelId, categoryId: $categoryId) {
  73. id
  74. views
  75. }
  76. }
  77. `
  78. export type AddVideoView = {
  79. addVideoView: EntityViewsInfo
  80. }
  81. export type AddVideoViewArgs = {
  82. videoId: string
  83. channelId: string
  84. categoryId?: string
  85. }