3 Reasons Why Astronomer is Betting on GraphQL

Photo cred: Warren Wong

3 Reasons Why Astronomer We Chose It:

Query Batching

Request #1
GET /users/123/bio
Response #1
{"bio":"lorem ipsum"}
Request #2
GET /users/123/photos
Response #2
{"photos": ["../image1.jpg", "../image2.jpg"]}
Request #1
POST /graphql
BODY { User(id:"123){
bio
photos
}
}
Response #1
{"bio":"lorem ipsum", "photos": ["../image1.jpg", "../image2.jpg"]}
// Request #1
GET /users/someone_on_github
// Response #1
{
"login": "someone_on_github",
"id": 1,
"avatar_url": "https://github.com/images/someone_on_github.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/someone_on_github",
"html_url": "https://github.com/someone_on_github",
"followers_url": "https://api.github.com/users/someone_on_github/followers",
"following_url": "https://api.github.com/users/someone_on_github/following{/other_user}",
"gists_url": "https://api.github.com/users/someone_on_github/gists{/gist_id}",
"starred_url": "https://api.github.com/users/someone_on_github/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/someone_on_github/subscriptions",
"organizations_url": "https://api.github.com/users/someone_on_github/orgs",
"repos_url": "https://api.github.com/users/someone_on_github/repos",
"events_url": "https://api.github.com/users/someone_on_github/events{/privacy}",
"received_events_url": "https://api.github.com/users/someone_on_github/received_events",
"type": "User",
"site_admin": false,
"name": "Someone On Github",
"company": "",
"blog": "",
"location": "San Francisco",
"email": "someone_on_github@somewherethatisntgithub.com",
"hireable": false,
"bio": "There once was...",
...
}
// Request #2
GET /users/:username/orgs
// Response #2
[
{
"login": "Org1",
"id": 1,
"url": "https://api.github.com/orgs/Org1",
"repos_url": "https://api.github.com/orgs/Org1/repos",
"events_url": "https://api.github.com/orgs/Org1/events",
"hooks_url": "https://api.github.com/orgs/Org1/hooks",
"issues_url": "https://api.github.com/orgs/Org1/issues",
"members_url": "https://api.github.com/orgs/Org1/members{/member}",
"public_members_url": "https://api.github.com/orgs/Org1/public_members{/member}",
"avatar_url": "https://github.com/images/Org1.gif",
"description": "A great organization"
},
...
]
// Request #3
GET /users/:username/repos
// Response #3
[
{
"id": 1234567890,
"owner": {...},
"name": "RepoA",
"full_name": "someone_on_github/RepoA",
"description": "This your first repo!",
"private": false,
"fork": false,
"url": "https://api.github.com/repos/octocat/RepoA",
"html_url": "https://github.com/octocat/RepoA"
},
...
]
// Request #1
query {
user(login:"someone_on_github") {
avatarUrl
bio
organizations(first:100) {
nodes {
name
}
}
contributedRepositories(first: 100) {
nodes {
name
}
}
}
}
// Response #1
{
"data": {
"user": {
"avatarUrl": "https://avatars3.githubusercontent.com/u/7362329?v=4",
"bio": "",
"organizations": {
"nodes": [
{
"name": "Org1",
"url": "https://github.com/Org1"
},
{
"name": "Org2",
"url": "https://github.com/Org2"
},
{
"name": "Org3",
"url": "https://github.com/Org3"
},
{
"name": "Org4",
"url": "https://github.com/Org4"
},
{
"name": "Org5",
"url": "https://github.com/Org5"
}
]
},
"contributedRepositories": {
"nodes": [
{
"name": "RepoA",
"url": "https://github.com/Org1/RepoA
},
{
"name": "RepoB",
"url": "https://github.com/Org3/RepoB"
},
{
"name": "RepoC",
"url": "https://github.com/Org1/RepoC"
},
{
"name": "RepoD",
"url": "https://github.com/Org2/RepoD"
},
{
"name": "RepoE",
"url": "https://github.com/Org1//RepoE"
}
]
}
}
}
}

Joining Rich Data Sources

Documentation and Deprecation

Watchouts

Setting it up isn’t magic

Authorization is Tricky

Rate Limiting is Harder

In Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Murray

Andrew Murray

Digital Product Designer, GraphQL API Developer, and UX Aficionado. Enjoys pulling concepts from the ether of ideas to make the real.