From ac77fc9f3f2212fbc5a7789fbbc41e8363f0c099 Mon Sep 17 00:00:00 2001 From: Bryan Clark Date: Thu, 17 Sep 2020 12:57:34 -0700 Subject: [PATCH 1/2] Add a GraphQL example --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index b74483b45..7e7e4a318 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,39 @@ jobs: console.log(result) ``` +### Run customer GraphQL queries + +You can use the `github.graphql` object to run custom GraphQL queries against the GitHub API. + +```yaml + +jobs: + list-packages: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const query = `query($owner:String!, $name:String!) { + repository(owner:$owner, name:$name){ + issues(first:100, labels: [$label]) { + nodes { + id + } + } + } + }`; + const variables = { + owner: context.repo.owner, + name: context.repo.repo, + label: 'wontfix' + } + const result = await github.graphql(query, variables) + console.log(result) + +``` + _(Note that this particular example only works for a public URL, where the diff URL is publicly accessible. Getting the diff for a private URL requires using the API.)_ From 91121b9cb30ed01528995b88da572c3af9404fc8 Mon Sep 17 00:00:00 2001 From: Bryan Clark Date: Thu, 17 Sep 2020 12:58:40 -0700 Subject: [PATCH 2/2] Fixup typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e7e4a318..4fc79d4ce 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ jobs: console.log(result) ``` -### Run customer GraphQL queries +### Run custom GraphQL queries You can use the `github.graphql` object to run custom GraphQL queries against the GitHub API.