Lambdas Support GraphQL AST

Request support for Dgraph Cloud Lambdas graphql function to have AST type support. It would make developing lambdas 10x better and give devs the peace of mind that their queries/mutations are type safe. They will then also be able to use popular graphql tools that work with the AST standard.

This code is from dgraph-lambda/dgraph.ts at main · dgraph-io/dgraph-lambda · GitHub

export async function graphql(query: string, variables: Record<string, any> = {}, authHeader?: AuthHeaderField): Promise<GraphQLResponse> {
  const headers: Record<string, string> = { "Content-Type": "application/json" };
  if (authHeader && authHeader.key && authHeader.value) {
    headers[authHeader.key] = authHeader.value;
  }
  const response = await fetch(`${process.env.DGRAPH_URL}/graphql`, {
    method: "POST",
    headers,
    body: JSON.stringify({ query, variables })
  })
  if (response.status !== 200) {
    throw new Error("Failed to execute GraphQL Query")
  }
  return response.json();
}

and it would be nice to have the definition something like this (the examples using graphql-request)

import { GraphQLClient } from 'graphql-request'
...
export async function graphql(query: string|DocumentNode, variables: Record<string, any> = {}, authHeader?: AuthHeaderField): Promise<GraphQLResponse> {
    const headers: Record<string, string> = { "Content-Type": "application/json" };
    // const vars:  Record<string, any> = variables?variables:{}
    const uri = `${process.env.DGRAPH_URL}/graphql`
    if (authHeader && authHeader.key && authHeader.value) {
      headers[authHeader.key] = authHeader.value;
    }
    if(typeof query === 'string'){
        const response = await fetch(uri, {
            method: "POST",
            headers,
            body: JSON.stringify({ query, variables })
          })
          if (response.status !== 200) {
            throw new Error("Failed to execute GraphQL Query")
          }
          return response.json();
    }
    const client = new GraphQLClient(uri, {headers: headers})
    const response = await client.request(query, variables)
    return response
  }