www.openweb.nl
Kafka and GraphQL:
Misconceptions and
Connections
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
▰Misconceptions about GraphQL
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
▰Misconceptions about GraphQL
▰Intro to Kafka
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
▰Misconceptions about GraphQL
▰Intro to Kafka
▰Misconceptions about Kafka
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
▰Misconceptions about GraphQL
▰Intro to Kafka
▰Misconceptions about Kafka
▰Combining Kafka with GraphQL
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
▰Misconceptions about GraphQL
▰Intro to Kafka
▰Misconceptions about Kafka
▰Combining Kafka with GraphQL
▰2 example POC’s
@GKlijs
www.openweb.nl
Contents
▰Intro to GraphQL
▰Misconceptions about GraphQL
▰Intro to Kafka
▰Misconceptions about Kafka
▰Combining Kafka with GraphQL
▰2 example POC’s
▰Main Takeaway
@GKlijs
www.openweb.nl
Bit about me
▰More than 5 years Kafka experience
@GKlijs
www.openweb.nl
Bit about me
▰More than 5 years Kafka experience
▰Added GraphQL subscriptions for
micronaut-graphql
@GKlijs
www.openweb.nl
Bit about me
▰More than 5 years Kafka experience
▰Added GraphQL subscriptions for
micronaut-graphql
▰Used GraphQL in production
server and client (JVM)
@GKlijs
www.openweb.nl
Intro to GraphQL
@GKlijs
www.openweb.nl
Intro to GraphQL
@GKlijs
▰Queries
www.openweb.nl
Intro to GraphQL
@GKlijs
▰Queries
▰Mutations
www.openweb.nl
Intro to GraphQL
@GKlijs
▰Queries
▰Mutations
▰Subscriptions
www.openweb.nl
Misconceptions about GraphQL
@GKlijs
GraphQL needs a Graph
Database
www.openweb.nl
Misconceptions about GraphQL
@GKlijs
GraphQL is owned by
Facebook
www.openweb.nl
Misconceptions about GraphQL
@GKlijs
GraphQL is better than
REST
www.openweb.nl
Misconceptions about GraphQL
@GKlijs
GraphQL is just for
frontend
www.openweb.nl
Misconceptions about GraphQL
@GKlijs
GraphQL is only for
javascript
www.openweb.nl
Intro to Kafka
@GKlijs
www.openweb.nl
Intro to Kafka
@GKlijs
www.openweb.nl
Intro to Kafka
@GKlijs
www.openweb.nl
Misconceptions about Kafka
@GKlijs
Kafka is just a message
queue
www.openweb.nl
Misconceptions about Kafka
@GKlijs
Kafka can’t be used to
mutate data
www.openweb.nl
Misconceptions about Kafka
@GKlijs
Kafka can’t be used to
mutate data
www.openweb.nl
Misconceptions about Kafka
@GKlijs
Kafka is hard to maintain
www.openweb.nl
Misconceptions about Kafka
@GKlijs
Kafka is hard to maintain
www.openweb.nl
Misconceptions about Kafka
@GKlijs
Kafka is hard to maintain
www.openweb.nl
Misconceptions about Kafka
@GKlijs
It’s not possible to do
queries on Kafka
www.openweb.nl
Misconceptions about Kafka
@GKlijs
It’s not possible to do
queries on Kafka
www.openweb.nl
Connecting the technologies
@GKlijs
How to get the types?
www.openweb.nl
Connecting the technologies
@GKlijs
How to get the types?
● Schema Registry
www.openweb.nl
Connecting the technologies
@GKlijs
How to get the types?
● Schema Registry
● Schema first
www.openweb.nl
Connecting the technologies
@GKlijs
How to get the types?
● Schema Registry
● Schema first
● Relation to topics
www.openweb.nl
Connecting the technologies
@GKlijs
How/if to implement the operations?
● Query
www.openweb.nl
Connecting the technologies
@GKlijs
How/if to implement the operations?
● Query
● Mutation
www.openweb.nl
Connecting the technologies
@GKlijs
How/if to implement the operations?
● Query
● Mutation
● Subscription
www.openweb.nl
Connecting the technologies
@GKlijs
Authentication,
authorization and security?
www.openweb.nl
Connecting the technologies
@GKlijs
Authentication,
authorization and security?
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
https://gklijs.tech/a
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
query {
PERSONS_BY_BIRTHYEAR(BIRTHYEAR: 1983){
BIRTHYEAR
TOTAL
}
}
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
{
"data": {
"PERSONS_BY_BIRTHYEAR": {
"BIRTHYEAR": 1983,
"TOTAL": 1
}
}
}
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
mutation {
PERSONS (
ID_KEY: "gklijs" ID: "gklijs"
FIRST_NAME: "Gerard" LAST_NAME: "Klijs"
BIRTHDAY: { YEAR: 1983 MONTH: 8 DAY: 23
}
){ statusCode }
}
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
{
"data": {
"PERSONS": {
"statusCode": 200
}
}
}
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
subscription {
PERSONS_BY_BIRTHYEAR {
BIRTHYEAR
TOTAL
}
}
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
{
"data": {
"PERSONS_BY_BIRTHYEAR": {
"BIRTHYEAR": 1983,
"TOTAL": 2
}
}
}
www.openweb.nl
2 example POC’s: ksqlDB
@GKlijs
{
"data": {
"PERSONS_BY_BIRTHYEAR": {
"BIRTHYEAR": 1983,
"TOTAL": 3
}
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
https://gklijs.tech/b
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
query {
transaction_by_id(id: 1){
descr
iban
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
{
"data": {
"transaction_by_id": {
"descr": "initial funds",
"iban": "NL66OPEN0000000000"
}
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
mutation {
get_account(username: "gerardklijs",
password: "test1234") {
iban
token
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
{
"data": {
"get_account": {
"iban": "NL32OPEN0116336786",
"token": "64863395589341241872"
}
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
subscription {
stream_transactions(iban:
"NL66OPEN0000000000") {
id
new_balance
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
{
"stream_transactions": {
"id": 7,
"new_balance": "€1.000.026,00",
"descr": "test for presentation"
}
}
www.openweb.nl
2 example POC’s: CQRS
@GKlijs
{
"stream_transactions": {
"id": 9,
"new_balance": "€1.000.045,00",
"descr": "another test"
}
}
www.openweb.nl
Main Takeaway
@GKlijs
GraphQL opens up some interesting
possibilities used with Kafka.
Bridging between backend and frontend,
with lots of ways to do it.

Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web