You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

116 lines
2.2 KiB

  1. import apollo from "../../../lib/apollo";
  2. async function newsByCompanyId(companyId){
  3. var res = apollo.query(
  4. `
  5. query($input: ID!){
  6. contents(sort:"publishedAt:desc" filters:{Type:{eq:"News"} Company:{id:{eq:$input}}}){
  7. data{
  8. id
  9. attributes{
  10. Title
  11. publishedAt
  12. Image{
  13. data{
  14. attributes{
  15. url
  16. }
  17. }
  18. }
  19. }
  20. }
  21. }
  22. }
  23. `,"",{
  24. "input" : companyId
  25. }
  26. );
  27. return res;
  28. }
  29. async function newsById(id){
  30. var res = await apollo.query(
  31. `
  32. query($input: ID!){
  33. content(id:$input){
  34. data{
  35. attributes{
  36. Company{
  37. data{
  38. id
  39. attributes{
  40. Name
  41. Description
  42. Address
  43. Phone
  44. Email
  45. }
  46. }
  47. }
  48. Title
  49. Image{
  50. data{
  51. attributes{
  52. url
  53. }
  54. }
  55. }
  56. Description
  57. publishedAt
  58. }
  59. }
  60. }
  61. }`,"",{
  62. "input":id
  63. }
  64. );
  65. return res;
  66. }
  67. async function newsByCompanyName(name,pageSize=999,page=1){
  68. var res = await apollo.query(
  69. `
  70. query($input: String!){
  71. contents(sort:"publishedAt:desc" filters:{Type:{eq:"News"} Company:{Name:{eq:$input}}} pagination:{pageSize:${pageSize},page:${page}}){
  72. meta{
  73. pagination{
  74. pageCount
  75. }
  76. }
  77. data{
  78. id
  79. attributes{
  80. Company{
  81. data{
  82. id
  83. attributes{
  84. Name
  85. Description
  86. }
  87. }
  88. }
  89. Title
  90. Image{
  91. data{
  92. attributes{
  93. url
  94. }
  95. }
  96. }
  97. publishedAt
  98. }
  99. }
  100. }
  101. }`,"",{
  102. "input":name
  103. }
  104. );
  105. return res;
  106. }
  107. module.exports = {
  108. newsById:newsById,
  109. newsByCompanyId:newsByCompanyId,
  110. newsByCompanyName:newsByCompanyName
  111. };