export function removeTypeName<T>(obj: T): T {
  if (Array.isArray(obj)) {
    return obj.map(removeTypeName) as any
  } else if (typeof obj === "object" && obj !== null) {
    const { __typename: _, ...newObj } = obj as any
    return Object.keys(newObj).reduce(
      (acc, key) => {
        acc[key] = removeTypeName(newObj[key])
        return acc
      },
      Object.create(Object.getPrototypeOf(obj)),
    )
  } else {
    return obj
  }
}
