Kristoffer Brabrand
Senior developer @ Behalf
GraphQL: A graph oriented way to think about and explore data
[without the data actually having to be in
a graph database any particular structure,
database or format at all]
1. frontend view specific endpoints in your API
2. huge payloads with loads of data your view doesn't need
3. many API requests per view
query Query {
movie(id:196000) {
id
title
}
}{
"data": {
"movie": {
"id": 196000,
"title": "Killer Sloths III"
}
}
}query Query {
movie(id:196000) {
id
title
actors {
id,
firstName,
lastName
}
reviews {
id,
name,
rating,
comment
}
}
}{
"data": {
"movie": {
"id": 196000,
"title": "Killer Sloths III",
"actors": [
{
"id": 1234,
"firstName": "Alice",
"lastName": "Webb"
},
...
],
"reviews": [
{
"id": 123,
"name": "Alf Sim",
"rating": 1,
"comment": "It sucks!"
},
...
]
}
}
}query Query {
actor(id:1234) {
id
firstName
lastName
movies {
id
title
}
}
}{
"data": {
"actor": {
"id": 1234,
"firstName": "Alice",
"lastName": "Webb",
"movies": [
{
"id": 196000,
"title": "Killer Sloths III"
},
...
]
}
}
}
You don't want abuse. There's a few ways around it.
Upload allowed queries to the registry build-time and allow only those queries uploaded to the registry to be performed.
Note: requires a an active team subscription for Apollo
https://github.com/kbrabrand/graphql-intro
By Kristoffer Brabrand