Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize GraphQL args #782

Merged
merged 13 commits into from
Jan 15, 2025
Merged

Conversation

wd60622
Copy link
Collaborator

@wd60622 wd60622 commented Jan 8, 2025

Describe what this PR does / why we need it

This generalizes the internals used in the gh.graph function. This allows for some more flexible queries including for list of fields. For instance:

local gh = require "octo.gh"

local query = [[
query($owner: String!, $name: String!, $num_issues: Int!, $states: [IssueState!]) {
  repository(owner: $owner, name: $name) {
    issues(last: $num_issues, states: $states) {
      nodes {
        title
      }
    }
  }
}
]]


gh.graphql {
  query = query,
  fields = {
    num_issues = 10,
    owner = "pwntester",
    name = "octo.nvim",
    states = { "OPEN", "CLOSED" },
  },
  jq = ".data.repository.issues.nodes | map(.title)",
  opts = {
    cb = function(output, stderr)
      vim.print(output)
      vim.print(stderr)
    end
  }
}

Note

This doesn't support passing the whole input for mutations which I elaborate upon in #787

Does this pull request fix one issue?

Describe how you did it

Describe how to verify it

Special notes for reviews

Checklist

  • Passing tests and linting standards
  • Documentation updates in README.md and doc/octo.txt

@wd60622 wd60622 merged commit 345ac95 into pwntester:master Jan 15, 2025
2 checks passed
@wd60622 wd60622 deleted the generalize-graphql-interal branch January 15, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant