GraphQL Query For Cloudflare SQL query

GraphQL Query For Cloudflare SQL query


0

Any Cloudflare and GraphQL Expert here??

Struggling with converting below SQL query into GraphQL, any help would be appreciated.

SELECT m.month_end_date as month_end_date
--Account Details
, c.account_pubname as account_name
, m.user_id as account_id
, z.zone_name as zone_name
, z.zone_plan as zone_rate_plan
--Requests
, sum(m.cached_request_count) as monthly_cached_requests
, sum(m.request_count) - sum(m.cached_request_count) as monthly_uncached_requests
, sum(m.request_count) as monthly_requests
--Data Transfer
, sum(m.transferred_bytes)/1e9 as monthly_data_transfer_gb
FROM `cloudflare-bi.ida.requests_monthly` m
JOIN `cloudflare-bi.ida_base.customer` c ON m.user_id = c.account_id
JOIN `cloudflare-bi.ida.zone` z ON m.zoneid  = z.zone_id
 
#Enter Date below in format: 'Year-Month-Day'
WHERE month_end_date between '2023-01-01' AND '2023-07-31'
AND zone_plan = 'XYZ'
 
#Enter Account ID(s) below
AND m.user_id IN (
    123123, 321321
    )
group by 1,2,3,4,5;

Expecting GraphQL of this SQL

New contributor

Ashish Panwar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1 Answer
1


0

It is not straight forward to get the GQL query from your given SQL query, It also depends on the resolvers and schema that you have created on GQL. But it will look more or less like this.

query {
  monthlyData(
    startDate: "2023-01-01",
    endDate: "2023-07-31",
    zonePlan: "XYZ",
    accountIds: [123123, 321321]
  ) {
    monthEndDate
    accountDetails {
      accountName
      accountId
      zoneName
      zoneRatePlan
    }
    requests {
      monthlyCachedRequests
      monthlyUncachedRequests
      monthlyRequests
    }
    dataTransfer {
      monthlyDataTransferGB
    }
  }
}



Leave a Reply

Your email address will not be published. Required fields are marked *