Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wtnabe/gas-github-graphql-request
GitHubGraphQLRequest Library for Google Apps Script
https://github.com/wtnabe/gas-github-graphql-request
gas-library google-apps-script spreadsheet
Last synced: 13 days ago
JSON representation
GitHubGraphQLRequest Library for Google Apps Script
- Host: GitHub
- URL: https://github.com/wtnabe/gas-github-graphql-request
- Owner: wtnabe
- License: bsd-2-clause
- Created: 2022-11-24T11:11:58.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-13T23:29:06.000Z (about 2 years ago)
- Last Synced: 2024-11-13T09:44:45.888Z (2 months ago)
- Topics: gas-library, google-apps-script, spreadsheet
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHubGraphQLRequest for Google Apps Script
GitHubGraphQLRequest Library for Google Apps Script Project ( **Sheets Container-bound** script )
## Prerequisite
Sheets Container-bound script Project.
## How to Use
### 0. Prepare Sheet
This library is for Spreadsheet Container-bound Script as it adds menus to Spreadsheet.
### 1. Add Library code
Choose one of them please.
1. add Project ID for your project as Library `14hP6p8PPzAy_yclpF-kXDSIpylKEDx-iJvMJtd1DSJJzJVV8miYzv_fS`
2. Copy and Paste this codeI would recommend #2 for speed of execution, but #1 is also a good option for administrative costs.
### 2. Write setup code
open Script Editor
```javascript
function onOpen () {
GitHubGraphQLRequest.registerGhgraph()
}
```### 3. Prepare Your Token
Set your GitHub Access Token into UserProperty with menu `[ GitHub Token ]`
### 4. Write Your Google Apps Script Code
example
```javascript
/**
* @returns {object}
* @customfunction
*/
function request () {
try {
const body = JSON.parse(
GitHubGraphQLRequest.request(query)
.getContentText()
)
return transform(body...nodes)
} catch (e) {
console.error(e)
return [['Something', 'wrong']]
}
}
````transform()` is a function that transforms a nested JavaScript Object into an Array of Arrays ( e.g. [ [], [], ...] ) for Spreadsheet.
### 5. call function from Spreadsheet
```javascript
=request()
```