Skip to content

Instantly share code, notes, and snippets.

@dhmlau
Last active June 12, 2021 00:22
Show Gist options
  • Save dhmlau/4fa10459f5e625ea77c6101615a3c401 to your computer and use it in GitHub Desktop.
Save dhmlau/4fa10459f5e625ea77c6101615a3c401 to your computer and use it in GitHub Desktop.
GHQueryService
export interface GhQueryService {
// this is where you define the Node.js methods that will be
// mapped to REST/SOAP/gRPC operations as stated in the datasource
// json file.
// -------------------------------------------------------
// Add the three methods here.
// Make sure the function names and the parameter names matches
// the ones you defined in the datasource
getIssuesByLabel(repo: string, label: string): Promise<QueryResponse>;
getIssuesByURL(url: string): Promise<QueryResponse>;
getIssuesWithQueryString(repo:string, querystring: string): Promise<QueryResponse>;
}
// The payload of the response contains the header and the body,
// because we set "fullResponse: true".
export interface QueryResponse {
headers: any;
body: QueryResponseBody;
}
// Inside the response body, it has the total_count and a list of
// GitHub issues
export interface QueryResponseBody {
total_count: number;
items: IssueInfo[];
}
// The returning GitHub issues have much more information than the following
// properties. We only pick the ones we need.
export class IssueInfo {
title: string;
html_url: string;
state: string;
created_at: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment