queryTemplates.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // this file will be copied to `/generated` folder; provides GraphQL query examples to GraphQL PLayground
  2. import {
  3. IQueryTemplate,
  4. queryTemplateUtils,
  5. } from '@apollographql/graphql-playground-react/lib/components/Playground/QueryTemplates/templateUtils'
  6. // fields that will be ignored by autofill
  7. const commonIgnoredFields = ['deletedAt', 'createdById', 'updatedById', 'deletedById', 'version']
  8. const exampleDate = `"2018-01-31 23:59"`
  9. export const queryTemplates: IQueryTemplate[] = [
  10. ...queryTemplateUtils.getOneGetAllTemplates('video', 'videos', 'videos', commonIgnoredFields),
  11. {
  12. title: 'Featured videos',
  13. description: 'Get all featured videos.',
  14. ignoredFields: commonIgnoredFields,
  15. query: `query {
  16. ${queryTemplateUtils.descriptionMarker}
  17. videos(where: { isFeatured_eq: true }) { ${queryTemplateUtils.allPropsMarker} }
  18. }`,
  19. },
  20. {
  21. title: 'All recent videos',
  22. description: 'Get all videos after created or updated after the given date.',
  23. ignoredFields: commonIgnoredFields,
  24. query: `query {
  25. ${queryTemplateUtils.descriptionMarker}
  26. videos(where: {
  27. createdAt_gt: ${exampleDate},
  28. updatedAt_gt: ${exampleDate},
  29. }) { ${queryTemplateUtils.allPropsMarker} }
  30. }`,
  31. },
  32. ...queryTemplateUtils.getOneGetAllTemplates(
  33. 'video category',
  34. 'video categories',
  35. 'videoCategories',
  36. commonIgnoredFields
  37. ),
  38. {
  39. title: `All videos in category`,
  40. description: `Get all videos associated with the given video category.`,
  41. ignoredFields: commonIgnoredFields,
  42. query: `query {
  43. ${queryTemplateUtils.descriptionMarker}
  44. videos(where: { category: { id_eq: 1 } }) { ${queryTemplateUtils.allPropsMarker} }
  45. }`,
  46. },
  47. ...queryTemplateUtils.getOneGetAllTemplates('channel', 'channels', 'channels', commonIgnoredFields),
  48. ...queryTemplateUtils.getOneGetAllTemplates(
  49. 'channel category',
  50. 'channels categories',
  51. 'channelCategories',
  52. commonIgnoredFields
  53. ),
  54. {
  55. title: `Channel's videos`,
  56. description: `Get all videos associated with the given channel.`,
  57. ignoredFields: commonIgnoredFields,
  58. query: `query {
  59. ${queryTemplateUtils.descriptionMarker}
  60. videos(where: { channel: { id_eq: 1 } }) { ${queryTemplateUtils.allPropsMarker} }
  61. }`,
  62. },
  63. ...queryTemplateUtils.getOneGetAllTemplates('asset', 'assets', 'storageDataObjects', commonIgnoredFields),
  64. ...queryTemplateUtils.getOneGetAllTemplates('membership', 'memberships', 'memberships', commonIgnoredFields),
  65. ...queryTemplateUtils.getOneGetAllTemplates('curator group', 'curator groups', 'curatorGroups', commonIgnoredFields),
  66. ...queryTemplateUtils.getOneGetAllTemplates('worker', 'workers', 'workers', commonIgnoredFields),
  67. ].map(queryTemplateUtils.formatQuery)