Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Lessons Learned from Integrating Django & GraphQL
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Krzysztof Żuraw
January 26, 2018
Programming
310
0
Share
Lessons Learned from Integrating Django & GraphQL
A few lessons learned while working with GraphQL & Django.
Krzysztof Żuraw
January 26, 2018
More Decks by Krzysztof Żuraw
See All by Krzysztof Żuraw
TypeScript myths debunked
krzysztofzuraw
0
240
Solutions reviews
krzysztofzuraw
0
81
Other Decks in Programming
See All in Programming
cloudnative conference 2026 flyle
azihsoyn
0
170
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
130
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
250
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.9k
Kingdom of the Machine
yui_knk
2
1.5k
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
380
PHPer、Cloudflare に引っ越す
suguruooki
1
160
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.7k
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.2k
Road to RubyKaigi: Play Hard(ware)
makicamel
1
570
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Ruling the World: When Life Gets Gamed
codingconduct
0
220
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
280
A designer walks into a library…
pauljervisheath
211
24k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
How to make the Groovebox
asonas
2
2.2k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
140
Producing Creativity
orderedlist
PRO
348
40k
Making Projects Easy
brettharned
120
6.6k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Transcript
LESSONS LEARNED LESSONS LEARNED FROM INTEGRATING DJANGO & FROM INTEGRATING
DJANGO & GRAPHQL GRAPHQL Created by Krzysztof Żuraw
WHO AM I? WHO AM I? PYTHON AND JAVASCRIPT DEVELOPER
PYTHON AND JAVASCRIPT DEVELOPER AT AT BASED IN WROCŁAW. BASED IN WROCŁAW. STXNEXT STXNEXT
None
LESSON 1: GRAPHQL LESSON 1: GRAPHQL IS COOL IS COOL
IF YOU KNOW HOW TO USE IT IF YOU KNOW HOW TO USE IT
TECHNOLOGY STACK TECHNOLOGY STACK
None
None
None
ASK FOR WHAT YOU NEED ASK FOR WHAT YOU NEED
GET RESULTS GET RESULTS { allActors{ lastName } } { "data": { "allActors": [ { "lastName": "Travolta" }, { "lastName": "Jackson" }, } }
GET MANY RESOURCES IN A GET MANY RESOURCES IN A
SINGLE REQUEST SINGLE REQUEST { film(id: 1) { title actors { firstName lastName } } }
{ "data": { "film": { "title": "Pulp Fiction", "actors": [
{ "firstName": "John", "lastName": "Travolta" }, { "firstName": "Samuel L.", "lastName": "Jackson" }, ]}}
DATA MUTATION DATA MUTATION mutation CreateFilm { createFilm(film: { title:
"My cool title" }) { title id } } { "data": { "createFilm": { "title": "My cool title", "id": 123 } } }
mutation UpdateFilm { updateFilm(film: { title: "Totaly different title" })
{ title } } { "data": { "updateFilm": { "title": "Totaly different title", } } }
None
None
LESSON 2: GRAPHENE-PYTHON LESSON 2: GRAPHENE-PYTHON class Film(graphene.ObjectType): class Meta:
interfaces = (relay.Node, ) title = graphene.String() actors = graphene.List(Actor) air_date = graphene_datetime.DateTime() rating = graphene.Int()
{ "name": "film", "description": "The ID of the object", "args":
[ { "name": "id", "description": null, "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", "name": "ID", "ofType": null } }, "defaultValue": null } ], "type": { "kind": "OBJECT", "name": "Film", "ofType": null }, "isDeprecated": false
CONCLUSION CONCLUSION PYTHON HAS A GREAT GRAPHQL PYTHON HAS A
GREAT GRAPHQL LIBRARY LIBRARY BUT BUT You have to be aware that it is a new library
None
LESSON 3: GRAPHRELATED FIELD LESSON 3: GRAPHRELATED FIELD Why? Almost
like ForeginKey in Django but without existence checks
# one microservice class Film(models.Model): title = models.CharField(max_length=100) air_date =
models.DateField() actor = GraphRelatedField('Actor') # another microservice class Actor(models.Model): name = models.CharField(max_length=100) # usage actor_name = film.actor.name
CONCLUSION CONCLUSION WE WANT TO HAVE BETTER WE WANT TO
HAVE BETTER COMMUNICATION BETWEEN COMMUNICATION BETWEEN MICROSERVICES MICROSERVICES JUST TO JUST TO Merge them together
None
LESSON 4: NUMBER OF LESSON 4: NUMBER OF REQUESTS REQUESTS
Inspired by Django ORM `prefetch_related` Fetch list of objects using one HTTP query and place them in thread-safe attribute inside a context.
CACHING CACHING HTTP Headers caching
SET CACHING HEADERS TO SET CACHING HEADERS TO INFORM INFORM
For how long cache the response? When there is need for refetch data for different users using the `Vary` header
CACHE POLICY CACHE POLICY Short cache times - less than
1 minute
CONCLUSION CONCLUSION USING CACHING BY VARY HEADER AND USING CACHING
BY VARY HEADER AND PREFETCHING OBJECTS IS GOOD IDEA PREFETCHING OBJECTS IS GOOD IDEA
None
LESSON 5: AUTHENTICATION LESSON 5: AUTHENTICATION What? JWT Why?
CONCLUSION CONCLUSION CHOOSING JWT WAS A GOOD IDEA - IT
CHOOSING JWT WAS A GOOD IDEA - IT ALLOWS US TO STORE ADDITIONAL INFO ALLOWS US TO STORE ADDITIONAL INFO
LESSON 6: FRONTEND TOOLING LESSON 6: FRONTEND TOOLING
CONCLUSION CONCLUSION A LOT OF NEW LIBRARIES - NOT ALWAYS
A LOT OF NEW LIBRARIES - NOT ALWAYS MATURE MATURE
None
THIS IS THE END THIS IS THE END Thank you
My blog: krzysztofzuraw.com My twitter: @krzysztof_zuraw