SlideShare a Scribd company logo
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

More Related Content

What's hot

EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
Sebastiano Armeli
 
Modern JS with ES6
Modern JS with ES6Modern JS with ES6
Modern JS with ES6
Kevin Langley Jr.
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
Solution4Future
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
Domenic Denicola
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in Ruby
Larry Diehl
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
hesher
 
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
jspha
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
Maxym Kharchenko
 
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 - ES6
Nilesh Jayanandana
 
Ansible 202
Ansible 202Ansible 202
Ansible 202
Sebastian Montini
 
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
Maxym Kharchenko
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
dantleech
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modules
jtyr
 
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
devbash
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
Shmuel Fomberg
 
ssh.isdn.test
ssh.isdn.testssh.isdn.test
ssh.isdn.test
Chris Hallman
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
Troy Miles
 
Ruby on rails tips
Ruby  on rails tipsRuby  on rails tips
Ruby on rails tips
BinBin 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 Devs
Rami Sayar
 

What's hot (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
 

Similar to Echtzeitapplikationen mit Elixir und GraphQL

Python1
Python1Python1
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
Diacode
 
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
 
AkJS Meetup - ES6++
AkJS Meetup -  ES6++AkJS Meetup -  ES6++
AkJS Meetup - ES6++
Isaac Johnston
 
React native
React nativeReact native
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
Sami Said
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
Guillaume Laforge
 
Symfony + GraphQL
Symfony + GraphQLSymfony + GraphQL
Symfony + GraphQL
Alex Demchenko
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiD
CODEiD PHP Community
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
Mehmet Emin İNAÇ
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into Production
Jamie Winsor
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
megakott
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
Oon Arfiandwi
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
David Sanchez
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
cacois
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
sickill
 
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
Konstantin Sorokin
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
Rowan Merewood
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
Ben Scofield
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
Abdulsattar Mohammed
 

Similar to 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
 

Recently uploaded

All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
DevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps ServicesDevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps Services
seospiralmantra
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 

Recently uploaded (20)

All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
DevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps ServicesDevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps Services
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 

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