Last active
August 4, 2019 15:25
-
-
Save balwa/5f01aaae58bb959f1e77d892a9c1ac4c to your computer and use it in GitHub Desktop.
GraphQL github API v4 basic examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query Basic { | |
viewer { | |
login | |
id | |
} | |
} | |
query Second { | |
user(login: "<login-name>") { | |
repositories(first: 12) { | |
nodes { | |
name | |
} | |
totalCount | |
totalDiskUsage | |
} | |
} | |
} | |
mutation CreateRepo { | |
createRepository(input: {name: "hellographql", visibility: PUBLIC}) { | |
repository { | |
url | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation CreateRepo($input: CreateRepositoryInput!) { | |
createRepository(input: $input) { | |
repository { | |
url | |
} | |
} | |
} | |
# In query variables | |
{ | |
"input": { | |
"name": "hellographql", | |
"visibility": "PUBLIC" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query StarredRepos($first: Int = 10) { | |
user(login: "balwa") { | |
url | |
starredRepositories(first: $first, orderBy: {field: STARRED_AT, direction: DESC}) { | |
nodes { | |
url | |
} | |
} | |
} | |
} | |
query UserStatus{ | |
viewer{ | |
status { | |
createdAt | |
message | |
emoji | |
} | |
} | |
} | |
query UserGists{ | |
viewer{ | |
gists(first: 10) { | |
nodes { | |
...GistsNode | |
} | |
} | |
} | |
} | |
fragment GistsNode on Gist { | |
description | |
isPublic | |
url | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment