-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathgithub.ts
More file actions
41 lines (38 loc) · 896 Bytes
/
github.ts
File metadata and controls
41 lines (38 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { gql } from 'graphql-request';
import { gqlClient } from './common';
export type GitHubUserRepository = {
id: string;
owner: string;
name: string;
fullName: string;
url: string;
description: string | null;
stars: number;
forks: number;
language: string | null;
updatedAt: string;
};
export const USER_GITHUB_REPOSITORIES_QUERY = gql`
query UserGithubRepositories($userId: ID!) {
userGithubRepositories(userId: $userId) {
id
owner
name
fullName
url
description
stars
forks
language
updatedAt
}
}
`;
export const getUserGithubRepositories = async (
userId: string,
): Promise<GitHubUserRepository[]> => {
const result = await gqlClient.request<{
userGithubRepositories: GitHubUserRepository[];
}>(USER_GITHUB_REPOSITORIES_QUERY, { userId });
return result.userGithubRepositories;
};