|
- import apollo from "../../../lib/apollo";
-
- async function newsByCompanyId(companyId){
- var res = apollo.query(
- `
- query($input: ID!){
- contents(sort:"publishedAt:desc" filters:{Type:{eq:"News"} Company:{id:{eq:$input}}}){
- data{
- id
- attributes{
- Title
- publishedAt
- Image{
- data{
- attributes{
- url
- }
- }
- }
- }
- }
- }
- }
- `,"",{
- "input" : companyId
- }
- );
- return res;
- }
-
- async function newsById(id){
- var res = await apollo.query(
- `
- query($input: ID!){
- content(id:$input){
- data{
- attributes{
- Company{
- data{
- id
- attributes{
- Name
- Description
- Address
- Phone
- Email
- }
- }
- }
- Title
- Image{
- data{
- attributes{
- url
- }
- }
- }
- Description
- publishedAt
- }
- }
- }
- }`,"",{
- "input":id
- }
- );
- return res;
- }
-
- async function newsByCompanyName(name,pageSize=999,page=1){
- var res = await apollo.query(
- `
- query($input: String!){
- contents(sort:"publishedAt:desc" filters:{Type:{eq:"News"} Company:{Name:{eq:$input}}} pagination:{pageSize:${pageSize},page:${page}}){
- meta{
- pagination{
- pageCount
- }
- }
- data{
- id
- attributes{
- Company{
- data{
- id
- attributes{
- Name
- Description
- }
- }
- }
- Title
- Image{
- data{
- attributes{
- url
- }
- }
- }
- publishedAt
- }
- }
- }
- }`,"",{
- "input":name
- }
- );
- return res;
- }
-
- module.exports = {
- newsById:newsById,
- newsByCompanyId:newsByCompanyId,
- newsByCompanyName:newsByCompanyName
- };
|