How to use the apollo-server-micro.ApolloError function in apollo-server-micro

To help you get started, we’ve selected a few apollo-server-micro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github charliewilco / downwrite / utils / resolvers.ts View on Github external
export const verifyUniqueUser = async (
  { username, email }: Omit,
  userGetter: (...args: string[]) => Promise
) => {
  const user: IUser = await userGetter(username, email);

  if (user) {
    if (user.username === username) {
      throw new ApolloError("User name taken");
    }
    if (user.email === email) {
      throw new ApolloError("Email taken");
    }

    return;
  }

  return {
    username,
    email
  };
};
github charliewilco / downwrite / utils / resolvers.ts View on Github external
export const verifyUniqueUser = async (
  { username, email }: Omit,
  userGetter: (...args: string[]) => Promise
) => {
  const user: IUser = await userGetter(username, email);

  if (user) {
    if (user.username === username) {
      throw new ApolloError("User name taken");
    }
    if (user.email === email) {
      throw new ApolloError("Email taken");
    }

    return;
  }

  return {
    username,
    email
  };
};