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
Krzysztof Żuraw
January 26, 2018
Programming
310
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
250
Solutions reviews
krzysztofzuraw
0
82
Other Decks in Programming
See All in Programming
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
350
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
the container ship “Apple Silicon”@WWDC26 Recap -Japan-\(region).swift
shingangan
0
120
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
270
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
380
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.3k
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
220
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
210
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
160
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
260
5分で問診!Composer セキュリティ健康診断
codmoninc
0
970
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
490
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
So, you think you're a good person
axbom
PRO
2
2.1k
Abbi's Birthday
coloredviolet
3
9.3k
From π to Pie charts
rasagy
0
270
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Building an army of robots
kneath
306
46k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Fireside Chat
paigeccino
42
4k
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