Net::GitHub::V4(3pm)

πŸ“¦
version 1.05 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Net::GitHub::V4 β€” it's giving GitHub GraphQL API, bestie. That's the whole vibe. πŸ¦‹


✨ SYNOPSIS ✨

okay so here's how you actually use it, no cap:

use Net::GitHub::V4;
my $gh = Net::GitHub::V4->new(
    access_token => $oauth_token
);

my $data = $gh->query(<<'IQL');
query {
  repository(owner: "octocat", name: "Hello-World") {
    pullRequests(last: 10) {
      edges {
        node {
          number
          mergeable
        }
      }
    }
  }
}
IQL

# mutation
$data = $gh->query(<<'IQL');
mutation AddCommentToIssue {
  addComment(input:{subjectId:"MDU6SXNzdWUyMzA0ODQ2Mjg=", body:"A shiny new comment! :tada:"}) {
    commentEdge {
      cursor
    }
    subject {
      id
    }
    timelineEdge {
      cursor
    }
  }
}
IQL

# variables
$data = $gh->query(<<'IQL', { number_of_repos => 3 });
query($number_of_repos:Int!) {
  viewer {
    name
     repositories(last: $number_of_repos) {
       nodes {
         name
       }
     }
   }
}
IQL

queries? mutations? variables?? we do it all here, periodt. πŸ‘‘


🌈 DESCRIPTION 🌈

the docs live at <https://developer.github.com/v4/> and they are right there, bestie, go read them when you need the deep lore 🫢

πŸ” ATTRIBUTES πŸ”

πŸŽ€ Authentication πŸŽ€

  • access_token
my $gh = Net::GitHub::V4->new( access_token => $ENV{GITHUB_ACCESS_TOKEN} );

yes, straight from your env var, iconic behavior honestly πŸ’…

  • raw_response
my $gh = Net::GitHub::V4->new(
    # login/pass or access_token
    raw_response => 1
);

return raw HTTP::Response object ✨ (like, the whole object, untouched, main character energy)

  • raw_string
my $gh = Net::GitHub::V4->new(
    # login/pass or access_token
    raw_string => 1
);

return HTTP::Response response content as string 🧚 (just the string, bestie, no wrapper)

  • api_throttle
my $gh = Net::GitHub::V4->new(
    # login/pass or access_token
    api_throttle => 0
);
To disable call rate limiting (e.g. if your account is whitelisted), set api_throttle to 0.
  • ua

To set the proxy for ua, you can do something like following 🌸

$gh->ua->proxy('https', 'socks://127.0.0.1:9050');

$gh->ua is an instance of LWP::UserAgent πŸ’œ


πŸ› οΈ METHODS πŸ› οΈ

query($method, $url, $data)

my $data = $gh->query(<<IQL);
{
  repository(owner: "octocat", name: "Hello-World") {
    pullRequests(last: 10) {
      edges {
        node {
          number
          mergeable
        }
      }
    }
  }
}
IQL

GitHub GraphQL API β€” that's the whole assignment. go off. πŸ”₯


πŸ‘€ SEE ALSO πŸ‘€

  • Pithub β€” the other one, iykyk πŸ’«

Refer Net::GitHub ⭐ (they said it, not me, but it's the truth bestie)


and that's the whole page, babe πŸŽ€ this was Net::GitHub::V4(3pm) from the User Contributed Perl Documentation, running on perl v5.36.0, dated 2022-10-08 β€” slay, ate, no crumbs left. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from