1import { gql } from 'graphql-request';
2
3import { apiClient } from '../apiClient';
4
5export type UserData = {
6  id: string;
7  appCount: number;
8  username: string;
9  profilePhoto: string;
10  accounts: UserAccount[];
11  isExpoAdmin: boolean;
12};
13
14export type UserAccount = {
15  id: string;
16  name: string;
17  ownerUserActor?: {
18    username: string;
19    fullName?: string;
20    profilePhoto: string;
21  };
22};
23
24const query = gql`
25  {
26    meUserActor {
27      id
28      appCount
29      profilePhoto
30      username
31      isExpoAdmin
32
33      accounts {
34        id
35        name
36        ownerUserActor {
37          username
38          fullName
39          profilePhoto
40        }
41      }
42    }
43  }
44`;
45
46export async function getUserProfileAsync() {
47  const data = await apiClient.request(query);
48  return data.meUserActor as UserData;
49}
50