Skip to content

Instantly share code, notes, and snippets.

@donaldguy
Last active November 8, 2025 04:30
Show Gist options
  • Select an option

  • Save donaldguy/c89d1e0264815e3f997b0fb13b1e7f9c to your computer and use it in GitHub Desktop.

Select an option

Save donaldguy/c89d1e0264815e3f997b0fb13b1e7f9c to your computer and use it in GitHub Desktop.
GraphQL calls for adding repos to star lists
gh-starlists() {
gh api graphql --paginate --raw-field query='
query($endCursor: String) {
viewer {
lists(first: 100, after: $endCursor) {
nodes {
id
name
}
pageInfo {
hasNextPage
endCursor
}
}
}
}' \
--jq '.data.viewer.lists.nodes[]
| "\(.id)\t\(.name)"'| column -s $'\t' -t
}
gh-repo-id() {
gh api graphql -F o="${1%/*}" -F n="${1#*/}" -H X-Github-Next-Global-ID:1 \
-f query='
query ($o: String!, $n: String!) {
repository(owner: $o, name: $n) {
id
}
}' \
--jq '.data.repository.id'
}
gh-mv-repo-to-list() {
if ! echo "$1" | grep -q '^R_' ; then
printf "1st argument should be a GraphQL Repository.ID, starting with R_\ngot '%s'\n" $1 >&2; return 1
fi
if ! echo "$2" | grep -q '^UL_' ; then
printf "2nd argument should be a GraphQL UserList.ID, starting with UL_\ngot '%s'\n" $2 >&2; return 1
fi
gh api graphql -F l="$2" -F r="$1" -f query='
mutation ($l: ID!, $r: ID!) {
updateUserListsForItem(input:{
itemId: $r
listIds: [$l]
}) {
lists {name}
}
}' \
--jq '"repo now [only] on list: \([ .data.updateUserListsForItem.lists[].name ]| join(", "))"'
}
@donaldguy
Copy link
Author

@donaldguy
Copy link
Author

donaldguy commented Nov 8, 2025

Oh man, "fun" thing about going through this GraphQL mutation as of 8:30pm PST on September 7th :

It adds to list without actually starring

(ime w/ all official clients, including today with mobile apps, starring has been considered implied by just unfurling and choosing a list ;

and indeed right now still on web, un-starring removes from all lists, as a confirm modal will warn you/confirm.

I really thought they'd have this in the business logic too, but:

11-07 8  06  (Vivaldi) - Your list  -causing brew sh new additions - Vivaldi@2x

)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment