• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

helaili/github-graphql-action: An action which executes graphql queries

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

helaili/github-graphql-action

开源软件地址(OpenSource Url):

https://github.com/helaili/github-graphql-action

开源编程语言(OpenSource Language):

JavaScript 90.0%

开源软件介绍(OpenSource Introduction):

github-graphql-action

An action that acts a client for GitHub's GraphQL API and can be chained. It means you can use a first instance to execute a GraphQL query and use its output to execute a GraphQL mutation.

Check a sample workflow and sample GraphqQL queries

Input parameters

Parameter   Description
query Query file path within the repo. Required
outputFile The name of the file, relative to GITHUB_WORKSPACE, where the output will be stored.
url GraphQL endpoint URL. Defaults to https://api.github.com/graphql
accept Accept header to set in the query. Optional
logLevel Enable logging. Values are info, timer, debug, warn, error. Optional

Output parameter

Parameter   Description
queryResult The outcome of the query

Query file

The query file contains the GraphQL query or mutation to execute. Format is YAML based.

Static parameters

query: '
  query($owner:String!, $name:String!) {
    repository(owner:$owner, name:$name) {
  	 name
   }
  }'
variables:
  owner: helaili
  name: github-graphql-action
...
jobs:
  static-query:
    runs-on: ubuntu-16.04
    steps:
    - uses: actions/checkout@v2
    - uses: ./
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        query: samples/repository-static.query.yaml

Parameters defined in the worklow

Variables values can also come from extra input parameters.

query: '
  query($owner:String!, $name:String!) {
    repository(owner:$owner, name:$name) {
  	 name
   }
  }'
variables:
  owner:
    type: arg
    name: owner
  name:
    type: arg
    name: name
...
jobs:
  args-query:
    runs-on: ubuntu-16.04
    steps:
    - uses: actions/checkout@v2
    - uses: ./
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        query: samples/repository-args.query.yaml
        owner: helaili
        name: github-graphql-action

File based parameters

Variable values can also come from a file, typically event.json which contains the event which triggered the action workflow (in ../workflow) or an arbitrary file (relative to /github/workspace) containing the result from a previous action (declared using the output command line parameter). This file is then processed by a jq query in order to extract the scalar value needed for the GraphQL query.

You can optionally add a cast parameter in order to convert the jq output to an Int, Float or Boolean

query:'
  query($owner:String!, $name:String!) {
    repository(owner:$owner, name:$name) {
      name
    }
  }'
variables:
  owner:
    type: jq
    file: ../workflow/event.json
    query: '.repository.owner.login'
  name:
    type: jq
    file: ../workflow/event.json
    query: '.repository.name'
...
jobs:
  introspection-query:
    runs-on: ubuntu-16.04
    steps:
    - uses: actions/checkout@v2
    - uses: ./
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        query: samples/introspection.query.yaml
        logLevel: debug
        accept: application/vnd.github.elektra-preview+json

Mutation

query: '
  mutation pinIssue($issueId: ID!){
    pinIssue(input: { issueId: $issueId }) {
      issue {
        repository {
          id
        }
      }
    }
  }'
variables:
  issueId:
    type: jq
    file: ../workflow/event.json
    query: '.issue.node_id'



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap