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