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
0
260
Lessons Learned from Integrating Django & GraphQL
A few lessons learned while working with GraphQL & Django.
Krzysztof Żuraw
January 26, 2018
Tweet
Share
More Decks by Krzysztof Żuraw
See All by Krzysztof Żuraw
TypeScript myths debunked
krzysztofzuraw
0
230
Solutions reviews
krzysztofzuraw
0
74
Other Decks in Programming
See All in Programming
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
280
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
DMMオンラインサロンアプリのSwift化
hayatan
0
170
ErdMap: Thinking about a map for Rails applications
makicamel
1
580
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
250
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1.3k
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.3k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
630
ESLintプラグインを使用してCDKのセオリーを適用する
yamanashi_ren01
2
230
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
190
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
98
18k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Writing Fast Ruby
sferik
628
61k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
350
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Documentation Writing (for coders)
carmenintech
67
4.5k
Optimising Largest Contentful Paint
csswizardry
33
3k
BBQ
matthewcrist
85
9.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
For a Future-Friendly Web
brad_frost
176
9.5k
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