SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
Moritz Flucht
Echtzeitapplikationen mit 

Elixir & GraphQL
Backend
MORITZ FLUCHT
Software Developer @ AKRA GmbH
E-Mail: mofl@akra.de
Twitter: @moritzflucht
GitHub: @hauptbenutzer
AGENDA
GraphQL Elixir im Projekt
Was ist GraphQL?
„GraphQL is a query language designed to build
client applications by providing an intuitive and
flexible syntax and system for describing their data
requirements and interactions.“
GraphQL Spec — https://facebook.github.io/graphql/
Design Principles: Hierarchical
query { 

post(id: 42) { 

title 

comments { 

text 

author { 

name 

} 

} 

} 

}
{ 

"post": { 

"title": "Elixir @ code.talks", 

"comments": [{ 

"text": "Awesome!", 

"author": { 

"name": "Arthur Dent" 

} 

}] 

} 

}
Design Principles: Product-centric
query { 

post(id: 42) { 

title 

comments { 

text 

author { 

name 

} 

} 

} 

}
{ 

"post": { 

"title": "Elixir @ code.talks", 

"comments": [{ 

"text": "Awesome!", 

"author": { 

"name": "Arthur Dent" 

} 

}] 

} 

}
Design Principles: Client-specified queries
query { 

posts(limit: 3) { 

title 

image { 

url 

title 

} 

} 

}
query { 

posts { 

title 

abstract 

link
publishedDate
author { name } 

} 

}
Design Principles: Strong-typing
schema { 

query: RootQuery 

}


type RootQuery { 

post(id: Int!): Post

}

type Post { 

title: String 

author: Author 

comments: [Comment] 

}
type Comment { 

text: String 

author: Author 

} 



type Author { 

name: String 

} 

Design Principles: Introspec@ve
query { 

__schema { 

types { 

name 

} 

} 

}
{ 

" __schema": { 

"types": [ 

{"name": "Author"}, 

{"name": "Comment"}, 

{"name": "Post"} 

] 

} 

}
Weitere GraphQL Sprachfeatures
Unions
Interfaces
Direc@ves
Variables
Fragments
fragment postFields on Post { 

title, publishedDate 

}


query { 

post(id: 42) { 

...postFields, 

author { 

latestPosts { 

...postFields 

} 

} 

} 

}
Operations = Queries ∪ Mutations ∪ Subscriptions
Document = Operations ∪ Fragments
GraphQL Dokument
Elixir
Elixir
Funk@onale, dynamische Programmiersprache
Kompiliert nach und läuK auf Erlang VM
Nebenläufigkeit durch isolierte Prozesse und 

Message Passing
Elixir
current_process = self() 



# Spawn an Elixir process (not an operating system one!) 

spawn_link(fn -> 

send current_process, {:msg, "hello world"} 

end) 



# Block until the message is received 

receive do 

{:msg, contents} -> IO.puts contents 

end 

Neues Phoenix Projekt
$ mix phx.new --no-ecto --no-brunch disruption
├── config/
├── lib
│   ├── disruption
│   │   └── application.ex
│   ├── disruption.ex
│   ├── disruption_web
│   │   ├── channels
│   │   │   └── user_socket.ex
│   │   ├── controllers/
│   │   ├── endpoint.ex
│   │   └── router.ex
│   └── disruption_web.ex
└── mix.exs
Absinthe Schema schreiben
$ vi lib/disruption_web/schema.ex
defmodule DisruptionWeb.Schema do 

use Absinthe.Schema 



query do 

field :post, type: :post do 

arg :id, non_null(:integer) 

end 

end 

end
query { 

post(id: 42) { 

title 

comments { 

text 

author { 

name 

} 

} 

} 

}
defmodule DisruptionWeb.Schema do 

use Absinthe.Schema 



query do 

field :post, type: :post do 

arg :id, non_null(:integer) 

end 

end


object :post do 

field :title, :string 

field :author, :author 

field :published_date, :datetime 

field :comments, list_of(:comment) 

end 



object :author do 

field :name, :string 

field :email, :string 

end 



object :comment do 

field :text, :string 

field :author, :author 

end
defmodule DisruptionWeb.Schema do 

use Absinthe.Schema 



query do 

field :post, type: :post do 

arg :id, non_null(:id) 

resolve fn args, _context ->
Api.post_by_id(args[:id]) 

end 

end 

end












object :post do 

field :title, :string 

field :author, :author 

field :published_date, :datetime 

field :comments, list_of(:comment) do
resolve fn post, _args, _context ->
post
|> Map.get(:id)
|> Api.comments_for_post() 

end 

end 

end 





defmodule DisruptionWeb.Schema do 

use Absinthe.Schema 



query do 

field :post, type: :post do 

arg :id, non_null(:id) 

resolve fn args, _context ->
Api.post_by_id(args[:id]) 

end 

end 

end












object :post do 

field :title, :string 

field :author, :author 

field :published_date, :datetime 

field :comments, list_of(:comment) do 

resolve fn %{id: id}, _, _ -> 

Api.comments_for_post(id)

end

end

end
defmodule DisruptionWeb.Schema do 

use Absinthe.Schema 



object :message do 

field :name, :string 

field :text, :string 

field :room, :string 

end 

mutation do
field :send_message, :message do 

arg :room, non_null(:string) 

arg :name, non_null(:string) 

arg :text, non_null(:string) 

resolve fn args, _ -> 

{:ok, args} 

end 

end 

end 

subscription do
field :messages, list_of(:message) do
arg :room, non_null(:string) 

trigger :send_message,
topic: fn msg -> msg.room end

config fn args, _ -> 

{:ok, topic: args.room} 

end

end 

end 





defmodule DisruptionWeb.Schema do 

use Absinthe.Schema 



object :message do 

field :name, :string 

field :text, :string 

field :room, :string 

end 

input_object :msg_params do

field :room, non_null(:string) 

field :name, non_null(:string) 

field :text, non_null(:string) 

end

mutation do 

field :send_message, :message do 

arg :message, non_null(:msg_params) 



resolve fn args, _ -> {:ok, args} end

end
end

mutation do 

field :send_message, :message do 

arg :message, non_null(:msg_params) 



resolve fn msg, _ -> 

Absinthe.Subscription.publish(Endpoint, msg, messages: msg.room)


{:ok, args} 

end 

end 

end 

GraphQL im Projekt
GraphQL API
Elixir / Absinthe
DB
Cloud SQL
Index
ElasticSearch
Feeds
Elixir
academics.de
Rails
CMS
VueJS SPA
Learning: Elixir

Modulares, organisches Weiterentwickeln

Funk@onale Programmierung dankbar für Datenverarbeitung

Hohe Qualität an Packages
Learning: Mapping von Schema zu Business Logic


Resolver so dumm wie möglich, so schlau wie nö@g


Schema als Konsolidierung und Validierung

Use-Case-oriented / Product-centric
Learning: Scaling & Performance

Zwei GraphQL Pods für drei Portale

Subresolver für teure Opera@onen

Asynchrones Resolving nutzen
Learning: GraphQL Sprach Features & Tooling

Keine Union Types für Input Objects

GraphQL Tracing und Caching (z.B. Apollo Engine)

Öffentliches Schema ist öffentlich
Fazit
GraphQL/Elixir als Schlüsseltechnologien funk@oniert
Ausblick: Rails-Frontend ablösen
Referenzen & Leseliste
hcps://elixir-lang.org/
hcps://graphql.org/learn/
hcps://www.apollographql.com/engine
hcps://absinthe-graphql.org/
hcps://elixir-slackin.herokuapp.com/
hcps://elixir.akra.de/
Q&A

Weitere ähnliche Inhalte

Was ist angesagt?

EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is hereSebastiano Armeli
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6Solution4Future
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyLarry Diehl
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overviewhesher
 
Of Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library designOf Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library designjspha
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale Subbu Allamaraju
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Nilesh Jayanandana
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVMaxym Kharchenko
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generatorsdantleech
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modulesjtyr
 
Introducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHIntroducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHdevbash
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Ruby on rails tips
Ruby  on rails tipsRuby  on rails tips
Ruby on rails tipsBinBin He
 
What's New in ES6 for Web Devs
What's New in ES6 for Web DevsWhat's New in ES6 for Web Devs
What's New in ES6 for Web DevsRami Sayar
 

Was ist angesagt? (20)

EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
 
Modern JS with ES6
Modern JS with ES6Modern JS with ES6
Modern JS with ES6
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in Ruby
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
Of Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library designOf Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library design
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 
Ansible 202
Ansible 202Ansible 202
Ansible 202
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modules
 
Introducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHIntroducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASH
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
ssh.isdn.test
ssh.isdn.testssh.isdn.test
ssh.isdn.test
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Ruby on rails tips
Ruby  on rails tipsRuby  on rails tips
Ruby on rails tips
 
What's New in ES6 for Web Devs
What's New in ES6 for Web DevsWhat's New in ES6 for Web Devs
What's New in ES6 for Web Devs
 

Ähnlich wie Echtzeitapplikationen mit Elixir und GraphQL

Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...apidays
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDCODEiD PHP Community
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into ProductionJamie Winsor
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perlmegakott
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackDavid Sanchez
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
Kostis Sagonas: Cool Tools for Modern Erlang Program DevelopmenKostis Sagonas: Cool Tools for Modern Erlang Program Developmen
Kostis Sagonas: Cool Tools for Modern Erlang Program DevelopmenKonstantin Sorokin
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud CastlesBen Scofield
 

Ähnlich wie Echtzeitapplikationen mit Elixir und GraphQL (20)

Python1
Python1Python1
Python1
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
 
AkJS Meetup - ES6++
AkJS Meetup -  ES6++AkJS Meetup -  ES6++
AkJS Meetup - ES6++
 
React native
React nativeReact native
React native
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Symfony + GraphQL
Symfony + GraphQLSymfony + GraphQL
Symfony + GraphQL
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiD
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into Production
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
Kostis Sagonas: Cool Tools for Modern Erlang Program DevelopmenKostis Sagonas: Cool Tools for Modern Erlang Program Developmen
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 

Kürzlich hochgeladen (20)

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

Echtzeitapplikationen mit Elixir und GraphQL

  • 1. Moritz Flucht Echtzeitapplikationen mit 
 Elixir & GraphQL Backend
  • 2. MORITZ FLUCHT Software Developer @ AKRA GmbH E-Mail: mofl@akra.de Twitter: @moritzflucht GitHub: @hauptbenutzer
  • 5. „GraphQL is a query language designed to build client applications by providing an intuitive and flexible syntax and system for describing their data requirements and interactions.“ GraphQL Spec — https://facebook.github.io/graphql/
  • 6. Design Principles: Hierarchical query { 
 post(id: 42) { 
 title 
 comments { 
 text 
 author { 
 name 
 } 
 } 
 } 
 } { 
 "post": { 
 "title": "Elixir @ code.talks", 
 "comments": [{ 
 "text": "Awesome!", 
 "author": { 
 "name": "Arthur Dent" 
 } 
 }] 
 } 
 }
  • 7. Design Principles: Product-centric query { 
 post(id: 42) { 
 title 
 comments { 
 text 
 author { 
 name 
 } 
 } 
 } 
 } { 
 "post": { 
 "title": "Elixir @ code.talks", 
 "comments": [{ 
 "text": "Awesome!", 
 "author": { 
 "name": "Arthur Dent" 
 } 
 }] 
 } 
 }
  • 8. Design Principles: Client-specified queries query { 
 posts(limit: 3) { 
 title 
 image { 
 url 
 title 
 } 
 } 
 } query { 
 posts { 
 title 
 abstract 
 link publishedDate author { name } 
 } 
 }
  • 9. Design Principles: Strong-typing schema { 
 query: RootQuery 
 } 
 type RootQuery { 
 post(id: Int!): Post
 }
 type Post { 
 title: String 
 author: Author 
 comments: [Comment] 
 } type Comment { 
 text: String 
 author: Author 
 } 
 
 type Author { 
 name: String 
 } 

  • 10. Design Principles: Introspec@ve query { 
 __schema { 
 types { 
 name 
 } 
 } 
 } { 
 " __schema": { 
 "types": [ 
 {"name": "Author"}, 
 {"name": "Comment"}, 
 {"name": "Post"} 
 ] 
 } 
 }
  • 11. Weitere GraphQL Sprachfeatures Unions Interfaces Direc@ves Variables Fragments fragment postFields on Post { 
 title, publishedDate 
 } 
 query { 
 post(id: 42) { 
 ...postFields, 
 author { 
 latestPosts { 
 ...postFields 
 } 
 } 
 } 
 }
  • 12. Operations = Queries ∪ Mutations ∪ Subscriptions Document = Operations ∪ Fragments GraphQL Dokument
  • 14. Elixir Funk@onale, dynamische Programmiersprache Kompiliert nach und läuK auf Erlang VM Nebenläufigkeit durch isolierte Prozesse und 
 Message Passing
  • 15. Elixir current_process = self() 
 
 # Spawn an Elixir process (not an operating system one!) 
 spawn_link(fn -> 
 send current_process, {:msg, "hello world"} 
 end) 
 
 # Block until the message is received 
 receive do 
 {:msg, contents} -> IO.puts contents 
 end 

  • 16. Neues Phoenix Projekt $ mix phx.new --no-ecto --no-brunch disruption ├── config/ ├── lib │   ├── disruption │   │   └── application.ex │   ├── disruption.ex │   ├── disruption_web │   │   ├── channels │   │   │   └── user_socket.ex │   │   ├── controllers/ │   │   ├── endpoint.ex │   │   └── router.ex │   └── disruption_web.ex └── mix.exs
  • 17. Absinthe Schema schreiben $ vi lib/disruption_web/schema.ex defmodule DisruptionWeb.Schema do 
 use Absinthe.Schema 
 
 query do 
 field :post, type: :post do 
 arg :id, non_null(:integer) 
 end 
 end 
 end query { 
 post(id: 42) { 
 title 
 comments { 
 text 
 author { 
 name 
 } 
 } 
 } 
 }
  • 18. defmodule DisruptionWeb.Schema do 
 use Absinthe.Schema 
 
 query do 
 field :post, type: :post do 
 arg :id, non_null(:integer) 
 end 
 end 
 object :post do 
 field :title, :string 
 field :author, :author 
 field :published_date, :datetime 
 field :comments, list_of(:comment) 
 end 
 
 object :author do 
 field :name, :string 
 field :email, :string 
 end 
 
 object :comment do 
 field :text, :string 
 field :author, :author 
 end
  • 19.
  • 20. defmodule DisruptionWeb.Schema do 
 use Absinthe.Schema 
 
 query do 
 field :post, type: :post do 
 arg :id, non_null(:id) 
 resolve fn args, _context -> Api.post_by_id(args[:id]) 
 end 
 end 
 end 
 
 
 
 
 
 object :post do 
 field :title, :string 
 field :author, :author 
 field :published_date, :datetime 
 field :comments, list_of(:comment) do resolve fn post, _args, _context -> post |> Map.get(:id) |> Api.comments_for_post() 
 end 
 end 
 end 
 
 

  • 21. defmodule DisruptionWeb.Schema do 
 use Absinthe.Schema 
 
 query do 
 field :post, type: :post do 
 arg :id, non_null(:id) 
 resolve fn args, _context -> Api.post_by_id(args[:id]) 
 end 
 end 
 end 
 
 
 
 
 
 object :post do 
 field :title, :string 
 field :author, :author 
 field :published_date, :datetime 
 field :comments, list_of(:comment) do 
 resolve fn %{id: id}, _, _ -> 
 Api.comments_for_post(id)
 end
 end
 end
  • 22.
  • 23. defmodule DisruptionWeb.Schema do 
 use Absinthe.Schema 
 
 object :message do 
 field :name, :string 
 field :text, :string 
 field :room, :string 
 end 
 mutation do field :send_message, :message do 
 arg :room, non_null(:string) 
 arg :name, non_null(:string) 
 arg :text, non_null(:string) 
 resolve fn args, _ -> 
 {:ok, args} 
 end 
 end 
 end 
 subscription do field :messages, list_of(:message) do arg :room, non_null(:string) 
 trigger :send_message, topic: fn msg -> msg.room end
 config fn args, _ -> 
 {:ok, topic: args.room} 
 end
 end 
 end 
 
 

  • 24.
  • 25. defmodule DisruptionWeb.Schema do 
 use Absinthe.Schema 
 
 object :message do 
 field :name, :string 
 field :text, :string 
 field :room, :string 
 end 
 input_object :msg_params do
 field :room, non_null(:string) 
 field :name, non_null(:string) 
 field :text, non_null(:string) 
 end
 mutation do 
 field :send_message, :message do 
 arg :message, non_null(:msg_params) 
 
 resolve fn args, _ -> {:ok, args} end
 end end

  • 26. mutation do 
 field :send_message, :message do 
 arg :message, non_null(:msg_params) 
 
 resolve fn msg, _ -> 
 Absinthe.Subscription.publish(Endpoint, msg, messages: msg.room) 
 {:ok, args} 
 end 
 end 
 end 

  • 28. GraphQL API Elixir / Absinthe DB Cloud SQL Index ElasticSearch Feeds Elixir academics.de Rails CMS VueJS SPA
  • 29. Learning: Elixir
 Modulares, organisches Weiterentwickeln
 Funk@onale Programmierung dankbar für Datenverarbeitung
 Hohe Qualität an Packages
  • 30. Learning: Mapping von Schema zu Business Logic 
 Resolver so dumm wie möglich, so schlau wie nö@g 
 Schema als Konsolidierung und Validierung
 Use-Case-oriented / Product-centric
  • 31. Learning: Scaling & Performance
 Zwei GraphQL Pods für drei Portale
 Subresolver für teure Opera@onen
 Asynchrones Resolving nutzen
  • 32. Learning: GraphQL Sprach Features & Tooling
 Keine Union Types für Input Objects
 GraphQL Tracing und Caching (z.B. Apollo Engine)
 Öffentliches Schema ist öffentlich
  • 33. Fazit GraphQL/Elixir als Schlüsseltechnologien funk@oniert Ausblick: Rails-Frontend ablösen
  • 35. Q&A