Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
feat: Switch to GraphQL (#48)
Browse files Browse the repository at this point in the history
* feat: switch to graphql
  • Loading branch information
Cahllagerfeld authored Jan 29, 2022
1 parent 69e4955 commit 15af1d2
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 106 deletions.
26 changes: 5 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
## [0.3.5](https://github.com/EddieHubCommunity/good-first-issue-finder/compare/v0.3.4...v0.3.5) (2022-01-28)


### Bug Fixes

* deployment ([#42](https://github.com/EddieHubCommunity/good-first-issue-finder/issues/42)) ([d2f28e8](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/d2f28e8905b2607e56ad1c0bb5da8b168347257c))


- deployment ([#42](https://github.com/EddieHubCommunity/good-first-issue-finder/issues/42)) ([d2f28e8](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/d2f28e8905b2607e56ad1c0bb5da8b168347257c))

## [0.3.4](https://github.com/EddieHubCommunity/good-first-issue-finder/compare/v0.3.3...v0.3.4) (2022-01-28)


### Bug Fixes

* github token secret ([74501d5](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/74501d5ed5fb9560267772e5b2754ece7983f9f5))


- github token secret ([74501d5](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/74501d5ed5fb9560267772e5b2754ece7983f9f5))

## [0.3.3](https://github.com/EddieHubCommunity/good-first-issue-finder/compare/v0.3.2...v0.3.3) (2022-01-28)


### Bug Fixes

* github token for sveltekit ([08468df](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/08468dfcc16dafcd8e13ef5316f6636a1c773935))


- github token for sveltekit ([08468df](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/08468dfcc16dafcd8e13ef5316f6636a1c773935))

## [0.3.2](https://github.com/EddieHubCommunity/good-first-issue-finder/compare/v0.3.1...v0.3.2) (2022-01-28)


### Bug Fixes

* deployment port ([#39](https://github.com/EddieHubCommunity/good-first-issue-finder/issues/39)) ([043296a](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/043296a9fea7c743d1ff437e8354dc4c4380666e))


- deployment port ([#39](https://github.com/EddieHubCommunity/good-first-issue-finder/issues/39)) ([043296a](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/043296a9fea7c743d1ff437e8354dc4c4380666e))

## [0.3.1](https://github.com/EddieHubCommunity/good-first-issue-finder/compare/v0.3.0...v0.3.1) (2022-01-28)


### Bug Fixes

* husky with docker file ([50c992a](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/50c992a0f272a787063ecb72f9e404a51b46fec7))



- husky with docker file ([50c992a](https://github.com/EddieHubCommunity/good-first-issue-finder/commit/50c992a0f272a787063ecb72f9e404a51b46fec7))
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"octokit": "^1.7.1"
},
"lint-staged": {
"*.{cjs,js,ts,css,scss,md,svelte}": [
"*.{cjs,js,ts,css,scss,svelte}": [
"eslint --fix",
"prettier --write --plugin-search-dir=. ."
]
}
}
}
8 changes: 4 additions & 4 deletions src/lib/components/issue-card.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import type { Item } from '../types/github.types';
import type { Node } from '../types/github.types';
import Card from './card.svelte';
export let issue: Item;
export let issue: Node;
</script>

<Card>
Expand All @@ -11,13 +11,13 @@
<img class="object-contain mr-4" src="/images/githubmark.svg" width="32" alt="github" />
<a
class="transition duration-100 underline hover:no-underline mr-4"
href={issue.html_url}
href={issue.url}
target="_blank"
>
{issue.title}</a
>
</div>
<a href={`https://gitpod.io/#${issue.html_url}`} target="_blank">
<a href={`https://gitpod.io/#${issue.url}`} target="_blank">
<img src="/images/open-in-gitpod.svg" alt="open-in-gitpod" /></a
>
</div>
Expand Down
80 changes: 12 additions & 68 deletions src/lib/types/github.types.ts
Original file line number Diff line number Diff line change
@@ -1,80 +1,24 @@
export type User = {
export type Owner = {
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
};

export type Label = {
id: any;
node_id: string;
url: string;
export type Repository = {
name: string;
color: string;
default: boolean;
description: string;
};

export type Reactions = {
url: string;
total_count: number;
'+1': number;
'-1': number;
laugh: number;
hooray: number;
confused: number;
heart: number;
rocket: number;
eyes: number;
owner: Owner;
};

export type Item = {
export type Node = {
url: string;
repository_url: string;
labels_url: string;
comments_url: string;
events_url: string;
html_url: string;
id: number;
node_id: string;
number: number;
title: string;
user: User;
labels: Label[];
state: string;
locked: boolean;
assignee?: any;
assignees: any[];
milestone?: any;
comments: number;
created_at: Date;
updated_at: Date;
closed_at?: any;
author_association: string;
active_lock_reason?: any;
body: string;
reactions: Reactions;
timeline_url: string;
performed_via_github_app?: any;
score: number;
repository: Repository;
};

export type Edge = {
node: Node;
};

export type IssueResponse = {
total_count: number;
incomplete_results: boolean;
items: Item[];
export type SearchResponse = {
issueCount: number;
edges: Edge[];
};
34 changes: 30 additions & 4 deletions src/routes/api/get-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,37 @@ export const get: RequestHandler = async () => {
const token = process.env['VITE_TOKEN'];
if (!token) return { status: 500, body: { message: 'please provide a token' } };
const octokit = new Octokit({ auth: token });
const response = await octokit.request('GET /search/issues', {
q: 'is:issue is:open label:"good first issue" org:EddieHubCommunity no:assignee',
});
const { search } = (await octokit.graphql(
`query EddieHubIssues($queryString: String! $skip: Int!) {
search(first: $skip, query: $queryString, type: ISSUE) {
issueCount
edges {
node {
... on Issue {
url
title
repository {
name
url
owner {
login
}
}
}
}
}
}
}`,
{
queryString: 'is:open label:"good first issue" org:EddieHubCommunity no:assignee',
skip: 50,
},
)) as any;

console.log(JSON.stringify(search));

return {
status: 200,
body: response.data,
body: search,
};
};
10 changes: 5 additions & 5 deletions src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const data = await res.json();
return {
props: {
data: data as IssueResponse,
data: data as SearchResponse,
},
};
}
Expand All @@ -21,12 +21,12 @@

<script lang="ts">
import IssueCard from '../lib/components/issue-card.svelte';
import type { IssueResponse } from '../lib/types/github.types';
export let data: IssueResponse;
import type { SearchResponse } from '../lib/types/github.types';
export let data: SearchResponse;
</script>

<div class="space-y-4">
{#each data.items as issue}
<IssueCard {issue} />
{#each data.edges as node}
<IssueCard issue={node.node} />
{/each}
</div>

0 comments on commit 15af1d2

Please sign in to comment.