Code Monkey home page Code Monkey logo

graphql-action's People

Contributors

3nids avatar aarondewes avatar achton avatar alexrintt avatar dependabot[bot] avatar firenza avatar gorohash avatar gr2m avatar greenkeeper[bot] avatar jeremycarroll avatar jovel avatar jsoref avatar kfcampbell avatar markiannucci avatar nickfloyd avatar octokitbot avatar os-jsplopes avatar oscard0m avatar pberthonneau avatar renovate[bot] avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-action's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: package.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: author, Invalid configuration option: keywords, Invalid configuration option: license, Invalid configuration option: main, Invalid configuration option: name, Invalid configuration option: packageRules[0].@actions/core, Invalid configuration option: packageRules[0].@octokit/action, Invalid configuration option: packageRules[1].@semantic-release/git, Invalid configuration option: packageRules[1].@zeit/ncc, Invalid configuration option: packageRules[1].js-yaml, Invalid configuration option: packageRules[1].semantic-release, Invalid configuration option: private, Invalid configuration option: release, Invalid configuration option: renovate, Invalid configuration option: scripts, Invalid configuration option: version

[MAINT]: Bump @actions/core version

Describe the need

Please consider bumping version of '@actions/core' dependency? Github recommends using 1.10.0 of @actions/core.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[DOCS]: What's the right way to pass JSON from one step to another?

Describe the need

I'm trying to parse the comments of issues, and label an issue if certain words are found. I'm using a query to get the comments of issues in the first step of my workflow, and a second step applies the label using the output.

The documentation for this action says that if I want to pass the output of a graphql query to another step, I should

To access deep values of outputs.data, use fromJSON()

but I can't figure out a way to do this that doesn't break in some way. Here's what I have currently:

  apply-issue-label:
    name: Apply label if needed
    steps:
      - uses: octokit/[email protected]
        name: Get the text of the issue and any of its comments
        id: get_issue_text
        with:
          query: |
            query getIssues($number: Int!, $owner: String!, $repo: String!) {
              repository(name: $repo, owner: $owner) {
                issue(number: $number) {
                  body
                  comments(last: 100) {
                    nodes {
                      body
                    }
                  }
                }
              }
            }
          variables: |
            owner: ${{ github.event.repository.owner.login }}
            repo: ${{ github.event.repository.name }}
            number: ${{ github.event.issue.number }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: actions/github-script@v6
        name: Parse issue comments
        with:
          script: |
            # This fails because the ${{ }} is literally substituted with the word `Array` before execution. Not sure why this is...
            const comments = ${{ fromJSON(steps.get_issue_text.outputs.data).repository.issue.comments.nodes }}
            console.log(comments)

            # This will also most likely fail because again the ${{ }} literally replaces what is in the issue body. If a malicious user puts in the right snippet of code, they can execute it here.
            const issueBody = ${{ fromJSON(steps.get_issue_text.outputs.data).repository.issue.body }}
            console.log(issueBody)

            let text = comments.map(({body}) => body)
            text.push(issueBody)

What's the right way to pass the JSON output from the first step to the second step for handling? I'd really like just the first step's JSON output as an Object in the second step.

Other stuff I've tried

  • Using JSON.parse(${{ steps.get_issue_text.outputs.data }}) fails because the argument is replaced with the literal output of get_issue_text, which isn't valid JS.
  • Using JSON.parse(`${{ steps.get_issue_text.outputs.data }}`) almost works, but will fail if there are newlines in the data, which aren't allowed in JSON, and will also fail if the data contains `.
  • Setting an environment variable to be ${{ steps.get_issue_text.outputs.data }} doesn't work; spaces aren't allowed
  • Setting an environment variable to be "${{ steps.get_issue_text.outputs.data }}" doesn't work because the GraphQL response contains ", causing a syntax error

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The push permission to the Git repository is required.

semantic-release cannot push the version tag to the branch master on remote Git repository with URL https://x-access-token:[secure]@github.com/octokit/graphql-action.

Please refer to the authentication configuration documentation to configure the Git credentials on your CI environment and make sure the repositoryUrl is configured with a valid Git URL.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Cannot set header information

Hi, i like your client for github, but i'm struggling to pass the accept parameter on header in order to use packages-preview api.
I've tried different approaches but i can't put it working.
Maybe if you put some examples how to customize the header on your documentation.

Best Regards,.

[FEAT]: Set Accept header for feature previews

Describe the need

I'd like to be able to query mergeStateStatus from the PullRequest object however to do so, I need to set the Accept header to application/vnd.github.merge-info-preview+json (docs).

I'm not sure of the best way to achieve this, but I imagine that it would be either to expose an additional input such as headers/accept_header or maybe even something via the env?

Thanks!

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

cannot use an integer argument

Using this query

- uses: octokit/[email protected]
        id: doc_info
        with:
          query: |
            query doc_info($owner: String!, $repo: String!, $pr_number: Int!) {
              repository(owner: $owner, name: $repo) {
                pullRequest(number: $pr_number) {
                 commits(first: 10) {
                   edges {
                     node {
                       commit {
                         oid
                         message
                       }
                     }
                   }
                 }
               }
              }
            }
          owner: ${{ github.event.repository.owner.name }}
          repo: ${{ github.event.repository.name }}
          pr_number: $ {{ github.event.pull_request.number }}

I am getting this error:

##[error]Variable $pr_number of type Int! was provided invalid value
##[error]Node run failed with exit code 1

How can I deal with it?
I don't see any casting to number method in the github context expression documentation

[BUG]: String parameters can unintentionally get parsed as numbers

What happened?

We have an action that takes a partial git SHA and resolves it to the complete SHA of a commit using a graphql query.

      - name: Get full git sha
        uses: octokit/[email protected]
        with:
          query: |
            query getFullCommitSha($owner: String!, $repo: String!, $sha: String!) {
              repository(owner: $owner, name: $repo) {
               object(expression: $sha) {
                  oid
                }
              }
            }
          owner: "${{ github.event.repository.owner.login }}"
          repo: "${{ github.event.repository.name }}"
          sha: "${{ steps.prior-step.outputs.partialCommitSha }}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This works fine for most SHAs but whenever a SHA can be interpreted as number, the action fails. We first noticed this with a SHA that was an exponent number e.g. 1234e3. For this case it was sufficient to add escaped qoutes to the SHA parameter in the YAML file i.e. sha: "\"${{ steps.prior-step.outputs.partialCommitSha }}\"".

However for purely numeric SHA substrings, the action still parses the string as an integer with no clearly documented way of preventing this behavior.

For now we use interpolation in the query itself, without using variables to get the correct behavior:

      - name: Get full git sha
        uses: octokit/[email protected]
        with:
          query: |
            query getFullCommitSha {
              repository(owner: "${{ github.event.repository.owner.login }}", name: "${{ github.event.repository.name }}") {
               object(expression: "${{ steps.prior-step.outputs.partialCommitSha }}") {
                  oid
                }
              }
            }

Versions

octokit/[email protected]

Relevant log output

##[debug]....Evaluating String:
##[debug]....=> 'partialCommitSha'
##[debug]..=> '05202765'
##[debug]=> '"05202765"'
##[debug]Result: '"05202765"'
Warning: Unexpected input(s) 'owner', 'repo', 'sha', valid inputs are ['query']
##[debug]Loading env
Run octokit/[email protected]
  
query getFullCommitSha($owner: String!, $repo: String!, $sha: String!) {
  repository(owner: $owner, name: $repo) {
   object(expression: $sha) {
      oid
    }
  }
}
> owner: ...
> repo: ...
> sha: 5202765
##[debug]GraphqlResponseError: Request failed due to following response errors:
##[debug] - Variable $sha of type String! was provided invalid value
##[debug]    at /home/runner/work/_actions/octokit/graphql-action/v2.2.23/dist/index.js:15207:13
##[debug]    at processTicksAndRejections (node:internal/process/task_queues:96:5)
##[debug]    at async main (/home/runner/work/_actions/octokit/graphql-action/v2.2.23/dist/index.js:1057:18) {

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG]: Minimal example fails with error

What happened?

Creating a new action with the minimal example and variables as listed in the README.md fails with the following error:

Error: Request failed due to following response errors:

  • Variable $owner of type String! was provided invalid value
  • Variable $repo of type String! was provided invalid value

Specifically, code as follows:

on:
    push:
        branches:
            - main

jobs:
  logLatestRelease:
    runs-on: ubuntu-latest
    steps:
      - uses: octokit/[email protected]
        id: get_latest_release
        with:
          query: |
            query release($owner:String!,$repo:String!) {
              repository(owner:$owner,name:$repo) {
                releases(first:1) {
                  nodes {
                    name
                    createdAt
                    tagName
                    description
                  }
                }
              }
            }
          variables: |
            owner: ${{ github.event.repository.owner.name }}
            repo: ${{ github.event.repository.name }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - run: "echo 'latest release: ${{ steps.get_latest_release.outputs.data }}'"

Versions

octokit/[email protected]

Relevant log output

Run octokit/[email protected]
  with:
    query: query release($owner:String!,$repo:String!) {
    repository(owner:$owner,name:$repo) {
      releases(first:1) {
        nodes {
          name
          createdAt
          tagName
          description
        }
      }
    }
  }
  
    variables: owner: myorg
  repo: github-project-playground
  
  env:
    GITHUB_TOKEN: ***
query release($owner:String!,$repo:String!) {
  repository(owner:$owner,name:$repo) {
    releases(first:1) {
      nodes {
        name
        createdAt
        tagName
        description
      }
    }
  }
}

> variables: [object Object]
> mediaType: undefined
Error: Request failed due to following response errors:
 - Variable $owner of type String! was provided invalid value
 - Variable $repo of type String! was provided invalid value

Code of Conduct

  • I agree to follow this project's Code of Conduct

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Cannot push to the Git repository.

semantic-release cannot push the version tag to the branch master on the remote Git repository with URL https://x-access-token:[secure]@github.com/octokit/graphql-action.

This can be caused by:


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Query runs fine in GraphQL Explorer but fails in Runner with Parse error on "-" (error)

See my snippet at https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/blob/main/.github/workflows/check-packages.yml#L119

    - name: Get Admin-Server GH Package URL
      uses: octokit/[email protected]
      id: get_latest_pkg_admin
      with:
        query: |
          query packages($owner:String!,$repo:String!) {
            repository(owner:${{ env.OWNER }},name:${{ env.REPO }}) {
              # /!\ '_' dash char. NOT supported in org.springframework.samples.petclinic.admin.${{ env.PRJ_PREFIX }}-${{ env.ADMIN_SERVER }}
              packages(first: 10, packageType: MAVEN, names: "org.springframework.samples.petclinic.admin.aca-spring-petclinic-admin-server") {
                edges {
                  node {
                    id
                    name
                    packageType
                    versions(first: 100) {
                      nodes {
                        id
                        version
                        files(first: 10) {
                          nodes {
                            name
                            url
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        # owner: ${{ github.repository_owner }} # ${{ github.event.repository.owner.name }}
        # repo: ${{ github.event.repository.name }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        # GITHUB_TOKEN: ${{ secrets.PKG_PAT }}
        OWNER: ${{ github.repository_owner }} # # ${{ github.event.repository.owner.name }} 
        REPO: ${{ github.event.repository.name }}

The query works fine in the GraphQL Explorer but the Runner fails with :

##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: github.repository_owner
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'repository_owner'
##[debug]=> 'ezYakaEagle44[2](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:2)'
##[debug]Result: 'ezYakaEagle442'
##[debug]Evaluating: github.event.repository.name
##[debug]Evaluating Index:
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating github:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'event'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'repository'
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'name'
##[debug]=> 'aca-java-petclinic-mic-srv'
##[debug]Result: 'aca-java-petclinic-mic-srv'
##[debug]Evaluating condition for step: 'Get Admin-Server GH Package URL'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Get Admin-Server GH Package URL
##[debug]Loading inputs
##[debug]Evaluating: format('query packages($owner:String!,$repo:String!) {{
##[debug]  repository(owner:{0},name:{1}) {{
##[debug]    # /!\ ''_'' dash char. NOT supported in org.springframework.samples.petclinic.admin.{2}-{[3](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:3)}
##[debug]    packages(first: 10, packageType: MAVEN, names: "org.springframework.samples.petclinic.admin.aca-spring-petclinic-admin-server") {{
##[debug]      edges {{
##[debug]        node {{
##[debug]          id
##[debug]          name
##[debug]          packageType
##[debug]          versions(first: 100) {{
##[debug]            nodes {{
##[debug]      '    packages(first: 10, packageType: MAVEN, names: "org.springframework.samples.petclinic.admin.aca-spring-petclinic-admin-server") {\n' +
##[debug]      '      edges {\n' +
##[debug]      '        node {\n' +
##[debug]      '          id\n' +
##[debug]      '          name\n' +
##[debug]      '          packageType\n' +
##[debug]      '          versions(first: 100) {\n' +
##[debug]      '            nodes {\n' +
##[debug]      '              id\n' +
##[debug]      '              version\n' +
##[debug]      '              files(first: 10) {\n' +
##[debug]      '                nodes {\n' +
##[debug]      '                  name\n' +
##[debug]      '                  url\n' +
##[debug]      '                }\n' +
##[debug]      '              }\n' +
##[debug]      '            }\n' +
##[debug]      '          }\n' +
##[debug]      '        }\n' +
##[debug]      '      }\n' +
##[debug]      '    }\n' +
##[debug]      '  }\n' +
##[debug]      '}\n'
##[debug]  },
##[debug]  headers: {
##[debug]    'access-control-allow-origin': '*',
##[debug]    'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
##[debug]    connection: 'close',
##[debug]    'content-encoding': 'gzip',
##[debug]    'content-security-policy': "default-src 'none'",
##[debug]    'content-type': 'application/json; charset=utf-8',
##[debug]    date: 'Tue, 0[4](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:4) Oct 2022 14:26:02 GMT',
##[debug]    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
##[debug]    server: 'GitHub.com',
##[debug]    'strict-transport-security': 'max-age=31[5](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:5)3[6](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:6)000; includeSubdomains; preload',
##[debug]    'transfer-encoding': 'chunked',
##[debug]    vary: 'Accept-Encoding, Accept, X-Requested-With',
##[debug]    'x-content-type-options': 'nosniff',
##[debug]    'x-frame-options': 'deny',
##[debug]    'x-github-media-type': 'github.v3; format=json',
##[debug]    'x-github-request-id': '0401:563F:FDCF62:20[7](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:7)6C[8](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:8)F:633C427A',
##[debug]    'x-ratelimit-limit': '1000',
##[debug]    'x-ratelimit-remaining': '1000',
##[debug]    'x-ratelimit-reset': '16648[9](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:9)7[16](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:16)2',
##[debug]    'x-ratelimit-resource': 'graphql',
##[debug]    'x-ratelimit-used': '0',
##[debug]    'x-xss-protection': '0'
##[debug]  },
##[debug]  response: { errors: [ [Object] ] },
##[debug]  errors: [
##[debug]    {
##[debug]      message: 'Parse error on "-" (error) at [2, [43](https://github.com/ezYakaEagle442/aca-java-petclinic-mic-srv/actions/runs/3182911312/jobs/5189509349#step:4:43)]',
##[debug]      locations: [Array]
##[debug]    }
##[debug]  ],
##[debug]  data: undefined
##[debug]}
Error: Request failed due to following response errors:
 - Parse error on "-" (error) at [2, 43]
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Get Admin-Server GH Package URL

@gr2m @jovel @achton @timrogers @3nids

[BUG]: Can't use ID types

What happened?

Using the following Action config, I get the error "Variable $itemId of type ID! was provided invalid value"

      - uses: octokit/[email protected]
        with:
          query: |          
            mutation setToReleased($itemId:ID!) {
              updateProjectV2ItemFieldValue(input: {fieldId: "PVTSSF_XXXXXXX", itemId: $itemId, projectId: "PVT_YYYYYYYYY", value: {text: "πŸš€ Released"}}) {
                projectV2Item {
                  updatedAt
                }
              }
            }
          itemId: ${{ fromJson(steps.milestone_issues.outputs.data).repository.milestone.issues.nodes[0].id }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The same query works with a "string" parameter works as expected in the GitHub GraphQL API Explorer

Versions

v2.x

Relevant log output

Warning: Unexpected input(s) 'itemId', valid inputs are ['query']
Run octokit/graphql-action@v[2](https://github.com/TeamConnectr/github-testing/actions/runs/3705750204/jobs/6280063209#step:5:2).x
  with:
    query: mutation setToReleased($itemId:ID!) {
    updateProjectV2ItemFieldValue(input: {fieldId: "PVTSSF_XXXXXXXXX", itemId: $itemId, projectId: "PVT_YYYYYYYYY", value: {text: "πŸš€ Released"}}) {
      projectV2Item {
        updatedAt
      }
    }
  }
  
    itemId: I_ZZZZZZZZZ
  env:
    GITHUB_TOKEN: ***

Code of Conduct

  • I agree to follow this project's Code of Conduct

octokit/graphql-action stopped working

This happened around Jul 08, 2022, 2:17 PM EDT. octokit/graphql-action just suddenly stopped working with the following errors:

Run octokit/[email protected]
  with:
    query: {
    repository(owner: "<github owner>", name: "<github repo>") {
      object(oid: "<a commit sha>") {
        ... on Commit {
          message
          author {
            user {
              login
            }
            email
          }
          committer {
            user {
              login
            }
          }
        }
      }
    }
  }
  
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.8.13/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.13/x64/lib
    GITHUB_TOKEN: ***
internal/fs/utils.js:269
    throw err;
    ^
Error: ENOENT: no such file or directory, open '/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/bridge.js'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:26968:60)
    at __webpack_require__ (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:24:31)
    at Object.<anonymous> (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:34426:5)
    at __webpack_require__ (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:24:31)
    at Object.<anonymous> (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:9432:18)
    at __webpack_require__ (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:24:31)
    at Object.<anonymous> (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:25686:15)
    at __webpack_require__ (/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/index.js:24:31) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/runner/work/_actions/octokit/graphql-action/v2.x/dist/bridge.js'
}

We didn't make any code change related to how we use octokit/graphql-action, can anyone take a look? Thanks!

Arrays in nodes or edges appear to be blank when running the action.

When running a query using the gh api graphql call the values in arrays are visible after the query runs. The query is written to check the ProjectV2ItemFieldIterationValue for an Issue, then have the ability to recall the value later in the action.

The issue in question is a member of a Project with a Iteration custom field.

Example using gh api graphql:

gh api graphql -f query='query get_story_and_iteration  {
  user(login: "kevinmcct") {
    repository(name: "GitHub-action-test") {
      issue(number: 34) {
        projectItems(first: 1) {
          nodes {
            fieldValueByName(name: "Sprint") {
              ... on ProjectV2ItemFieldIterationValue {
                title
              }
            }
          }
        }
      }
    }
  }
}' > sprint.json
cat sprint.json
{"data":{"repository":{"issue":{"title":"new issues with auto #34 12345678","projectItems":{"nodes":[{"fieldValueByName":{"title":"Sprint 2"}}]}}}}}

When running the same query using octokit/[email protected] in an action the query runs with no errors, but when trying to view the data returned by the query I can't see the data past the nodes [] section of the output data.

Example running octokit/[email protected]:

Run octokit/[email protected]
  with:
    query: query sprint ($owner:String!,$repo:String!,$gh_issue_number:Int!){
    user(login: $owner) {
      repository(name: $repo) {
        issue(number: $gh_issue_number) {
          projectItems(first: 1) {
            nodes {                          
              iteration:fieldValueByName(name: "Sprint") {
                ... on ProjectV2ItemFieldIterationValue {
                  title
                }
              }
            }
          }
        }
      }
    }
  }
  
    owner: kevinmcct
    repo: GitHub-action-test
    gh_issue_number: [3](https://github.com/kevinmcct/GitHub-action-test/actions/runs/3183587445/jobs/5190984944#step:2:3)[4](https://github.com/kevinmcct/GitHub-action-test/actions/runs/3183587445/jobs/5190984944#step:2:4)
  env:
    GITHUB_TOKEN: ***
query sprint ($owner:String!,$repo:String!,$gh_issue_number:Int!){
  user(login: $owner) {
    repository(name: $repo) {
      issue(number: $gh_issue_number) {
        projectItems(first: 1) {
          edges {
            node {                          
              iteration:fieldValueByName(name: "Sprint") {
                ... on ProjectV2ItemFieldIterationValue {
                  title
                }
              }
            }
          }
        }
      }
    }
  }
}

> owner: kevinmcct
> repo: GitHub-action-test
> gh_issue_number: [34](https://github.com/kevinmcct/GitHub-action-test/actions/runs/3183587445/jobs/5190984944#step:2:35)
Run echo 'Sprint Name: {
Sprint Name: {
  "user": {
    "repository": {
      "issue": {
        "projectItems": {
          "nodes": []
        }
      }
    }
  }
}

Am I missing some additional information when trying to recall the information or is there something strange happening in my query?

Here is the action I am using:

name: Advanced Sync issue to Azure DevOps work item

on:
  issues:
    types:
      [opened, edited, deleted, closed, reopened, labeled, unlabeled, assigned]
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  graphQL:
    runs-on: ubuntu-latest
    steps:
    - uses: octokit/[email protected]
      id: sprint
      with:
        query: |
          query sprint ($owner:String!,$repo:String!,$gh_issue_number:Int!){
            user(login: $owner) {
              repository(name: $repo) {
                issue(number: $gh_issue_number) {
                  projectItems(first: 1) {
                    nodes {
                      fieldValueByName(name: "Sprint") {
                        ... on ProjectV2ItemFieldIterationValue {
                          title
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        owner: kevinmcct
        repo: ${{ github.event.repository.name }}
        gh_issue_number: ${{ github.event.issue.number }}
    - run: "echo 'Sprint Name: ${{ steps.sprint.outputs.data }}'"

Error executing query

One of our actions threw an error earlier today and the error message implied that it should be reported:

Error: Something went wrong while executing your query. Please include 0781:5AD4:240C07:892C2B:61CC49CB when reporting this issue.

Screenshot from 2021-12-29 12-23-50

The workflow looks like this:

    steps:
      - uses: octokit/[email protected]
        with:
          headers: '{"GraphQL-Features": "projects_next_graphql"}'
          query: |
            mutation add_to_project($projectid:ID!,$contentid:ID!) {
              addProjectNextItem(input:{projectId:$projectid contentId:$contentid}) {
                projectNextItem {
                  id
                }
              }
            }
          projectid: ${{ env.PROJECT_ID }}
          contentid: ${{ github.event.issue.node_id }}
        env:
          PROJECT_ID: "PN_kwDOAM0swc1HvQ"
          GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}

I re-ran the workflow and it worked on second pass without any issues so urgency to investigate further from our side.

This action doesn't accept camelCase variables

I saw that here:

graphql-action/index.js

Lines 35 to 38 in 6ea3f9b

const inputName =
key.toLowerCase() === "input_mediatype"
? "mediaType"
: key.substr("INPUT_".length).toLowerCase();

We are parsing the inputs using toLowerCase() which results in providing the wrong query variable when executing it.

I don't know if it's expected or if it's already addressed but it is present in the latest release.

My below action fails:

name: Delete Discussion from outside collaborators
on:
  discussion_comment: 
    types: [created]

jobs:
  job1:
    runs-on: ubuntu-latest
    if: >
      (github.event_name == 'discussion_comment') && 
      (github.event.action == 'created') &&
      (github.event.comment.user.id == github.event.discussion.user.id) &&
      (github.event.comment.body == format('{0}{1}', 'DELETE MY POST ', github.event.discussion.title))
    steps:
      - name: Delete discussion through GitHub GraphQL API
        uses: octokit/[email protected]
        with:
          query: |
            mutation DeleteDiscussion($discussionId: ID!) {
              deleteDiscussion(input: { id: $discussionId }) {
                clientMutationId
              }
            }
          discussionId: ${{ github.event.discussion.node_id }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

with:

image

Error: Variable $discussionId of type ID! was provided invalid value

This happens because since we're providing the discussionid (note the lowercase) instead of discussionId, the actual value sent to the query var is undefined or whatever but not the value provided in the action.

The workaround is to provide declare lowercase variables in the GraphQL query string itself:

name: Delete Discussion from outside collaborators
on:
  discussion_comment: 
    types: [created]

jobs:
  job1:
    runs-on: ubuntu-latest
    if: >
      (github.event_name == 'discussion_comment') && 
      (github.event.action == 'created') &&
      (github.event.comment.user.id == github.event.discussion.user.id) &&
      (github.event.comment.body == format('{0}{1}', 'DELETE MY POST ', github.event.discussion.title))
    steps:
      - name: Delete discussion through GitHub GraphQL API
        uses: octokit/[email protected]
        with:
          query: |
-            mutation DeleteDiscussion($discussionId: ID!) {
+            mutation DeleteDiscussion($discussionid: ID!) {
-              deleteDiscussion(input: { id: $discussionId }) {
+              deleteDiscussion(input: { id: $discussionid }) {
                clientMutationId
              }
            }
           # optional change, since the input will be parsed as lowercase anyways.
-          discussionId: ${{ github.event.discussion.node_id }}
+          discussionid: ${{ github.event.discussion.node_id }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - run: "The issue was deleted by the author and can't be restored anymore."

I'm also playing with this action less than an hour so let me know if I am missing something.

Thanks.

Dependency Dashboard

This issue contains a list of Renovate updates and their statuses.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to ignore the schedule.

  • fix(deps): lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.


  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.