Hey guys I am trying to use async await in a resol...
# prisma-whats-new
k
Hey guys I am trying to use async await in a resolver function but I get this error regeneratorRuntime is not defined even when I used 'use_latest' flag
m
@kdichev you don't need the
user latest
flag.
Copy code
export default async (event: FunctionEvent<EventData>) => {
  try {
    // create simple api client
    const { email } = event.data
    const api = fromEvent(event).api('simple/v1');

    // get user by email
    const user: User = await getUserByEmail(api, email)
    .then(r => r.User)
}
async function getUserByEmail(api: GraphQLClient, email: string): Promise<{ User }> {
  const query = `
    query getUserByEmail($email: String!) {
      User(email: $email) {
        id
        name
        email
        emailVerified
      }
    }
  `
  const variables = { email }
  return api.request<{ User }>(query, variables)
}
how are you writing your async code? See the above for an example
k
I'm using legacy project will try to upgrade and get the right setup :)
m
got it. yeah the CLI framework is great