Skip to content

Instantly share code, notes, and snippets.

@saipraveen-a
Last active October 3, 2020 04:13
Show Gist options
  • Save saipraveen-a/18fcc32f3578d22c97506f14e4b3964a to your computer and use it in GitHub Desktop.
Save saipraveen-a/18fcc32f3578d22c97506f14e4b3964a to your computer and use it in GitHub Desktop.
GraphQL Reference Queries and Mutations

Get Repositories

query GetRepositories { repository(name: "test-bottle-app", owner: "saipraveen-a") { name parent { name } createdAt watchers { totalCount } languages { totalCount } } }

Get Organization Of User

query GetOrganizationOfUser { organization(login: "saipraveen-a") { name } }

Get User By Login

query GetUserByLogin { user(login: "saipraveen.a.iiit@gmail.com") { name company email } }

Get Logged In User

query LoggedInUser { viewer { login location name email company gists(last: 5) { nodes { name description createdAt url isPublic } } following(last: 3) { totalCount nodes { id name location } } followers(first: 1) { totalCount nodes { id company } } } }

Graph QL Alias

query LoggedInUser { viewer { login location name email company gists(last: 5) { nodes { name description createdAt url isPublic } } following(last: 3) { totalCount nodes { id name location } } firstFollower: followers(first: 1) { totalCount nodes { id company } } lastFollower: followers(last: 1) { totalCount nodes { id company } } } }

GraphQL Fragments

query LoggedInUser { viewer { login location name email company gists(last: 5) { nodes { name description createdAt url isPublic } } following(last: 3) { totalCount nodes { id name location } } firstFollower: followers(first: 1) { totalCount nodes { ...userInfo } } lastFollower: followers(last: 1) { totalCount nodes { ...userInfo } } } }

fragment userInfo on User { id company avatarUrl }

GraphQL Mutations

mutation ChangeStatus($input: ChangeUserStatusInput!) { changeUserStatus(input: $input) { clientMutationId status { message } } }

query ViewerInfo { viewer { login name status { id message } } }

{ "input": { "clientMutationId": "10101010", "message": "Testing changeStatus Mutation" } }

GraphQL Variables

query LoggedInUser($privacy: RepositoryPrivacy!) { viewer { login location name email company repositories(privacy: $privacy, last: 5) { nodes { name createdAt parent { id } } } gists(last: 5) { nodes { name description createdAt url isPublic } } following(last: 3) { totalCount nodes { id name location } } firstFollower: followers(first: 1) { totalCount nodes { ...userInfo } } lastFollower: followers(last: 1) { totalCount nodes { ...userInfo } } } }

fragment userInfo on User { id company avatarUrl }

{ "privacy": "PRIVATE" }

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