Skip to content

Commit

Permalink
Use repository affiliation GraphQL argument
Browse files Browse the repository at this point in the history
The GitHub GraphQL API now includes a mechanism to choose which
affiliations of the viewer's repositories that you'd like back. This
means that we can remove some logic from the client and instead lean on
the server to do that filtering for us - saving on requests and
bandwidth.
  • Loading branch information
bswinnerton committed Mar 10, 2017
1 parent 7c33390 commit 6098121
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
18 changes: 6 additions & 12 deletions Contents/Scripts/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ class Account {
return this._fetchRepositories();
});

return repositoryEdges.reduce(function(repositories, edge) {
let repo = edge.node;
let owner = new Account(repo.owner.login);

// Only return repositories that the account directly owns
if (owner.login === this.login) {
let repository = new Repository(owner, repo.name, repo.description);
repositories.push(repository);
}
return repositoryEdges.map(function(edge) {
let repo = edge.node;
let owner = new Account(repo.owner.login);

return repositories;
}.bind(this), []);
return new Repository(owner, repo.name, repo.description);
});
}

_fetchRepositories(cursor, allEdges) {
Expand All @@ -54,7 +48,7 @@ class Account {
const query = `
query($login: String!, $cursor: String) {
repositoryOwner(login: $login) {
repositories(first: 30, after: $cursor, orderBy: {field: PUSHED_AT, direction: DESC}) {
repositories(first: 30, after: $cursor, affiliation:[OWNER], orderBy: {field: PUSHED_AT, direction: DESC}) {
edges {
cursor
node {
Expand Down
3 changes: 1 addition & 2 deletions Contents/Scripts/bundle.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6098121

Please sign in to comment.