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
graphql in laravel(lighthouse-php)
Search
qazz92
February 21, 2020
Programming
0
200
graphql in laravel(lighthouse-php)
Graphql in laravel
by Comento
qazz92
February 21, 2020
Tweet
Share
Other Decks in Programming
See All in Programming
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.2k
AtCoder Conference 2025
shindannin
0
1.1k
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
200
Implementation Patterns
denyspoltorak
0
290
CSC307 Lecture 06
javiergs
PRO
0
690
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
610
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
580
Grafana:建立系統全知視角的捷徑
blueswen
0
330
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
How GitHub (no longer) Works
holman
316
140k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Side Projects
sachag
455
43k
Music & Morning Musume
bryan
47
7.1k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Typedesign – Prime Four
hannesfritz
42
2.9k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
130
Become a Pro
speakerdeck
PRO
31
5.8k
We Are The Robots
honzajavorek
0
160
Transcript
ݭష - ۾ With Laravel
RESTful API ?
RESTful API Method Route Action GET /post Ӗ ݾ۾ ੍ӝ
GET /post/:id ౠ Ӗ ੍ӝ POST /post Ӗ PUT/PATCH /post/:id Ӗ DELETE /post/:id Ӗ ઁ
RESTful API
ೞ݅…അपীࢲח… RESTful API Ex) Ӗਸ ઁೞݶ ನੋܳ غج۰Ҋ रযਃ! Ѥ
put ੋоਃ / delete ੋоਃ?
RESTful API
RESTful API GET /post/:id GET /comment/:postId GET /like/:postId
RESTful API GET /postAndCommentsAndLikes/:id
RESTful API Ӓؘ۠..
RESTful API ݽ߄ੌীࢲ ܲ Ѧ ୶оਵ۽ ࠁৈঠ ೠѢա, ࡐঠ ೠݶ?
=> /postAndCommentsAndLikes/:id?platform=mobile э api ܳ ܲ Ҕীࢲ ࢎਊ ೧ঠ ೞחؘ ӂೠ ୶оغযঠ ೠݶ? э api ܳ ܲ Ҕীࢲ ࢎਊ ೧ঠ ҙ҅о ୶о غঠ ೠݶ? …
RESTful API front-end ‘ apiীࢲ ݭష ࠁө ࣁਃ.’ back-end GET
/edu/camp/:id?mentor=1 ӝദ ‘ই! ݽ߄ੌীࢲח ࣗܳ ࡐࣁਃ’ front-end back-end ‘….’ front-end ٘ ࣻ back-end GET /edu/camp/:id?mentor=1&location=0 front-end ٘ ࣻ back-end ޙࢲ ١ সؘ back-end front-end ழޭפா࣌ ࠺ਊ ֫
RESTful API
None
GraphQL ױ ೠ ѐ end-point ೧ ௪ܻ झಖ(Schema)ী ٮۄ, ۄо
db ഐ!
front-end ‘ apiীࢲ ݭష ࠁ?’ front-end { camp(id: 214) {
mentor { name company } title back_img } } front-end ٘ ࣻ ࢲߡীࢲח ௪ܻ झಖ݅ ઓ! ৻ࠗ झಖա ޙࢲী ઓ X ழޭפா࣌ ࠺ਊ хࣗ GraphQL
GraphQL - Basic Query Mutation read data write data Type
model type user { id: ID! email: String! pw: String! } query { user(id: 1) { id email } } mutation { creaetUser ( email: "
[email protected]
" pw: “test” ) { id } }
GraphQL ଵ જؘ…Laravel ীࢲ যڌѱ ॳ…?
GraphQL Lighthouse-php https://lighthouse-php.com/
GraphQL Lighthouse-php ৵? ࠁా apollo! but ࢲߡ ҙܻ ӈଳ ?
eloquent ORM! ױ? ࠂೠ ௪ܻܳ ࢎਊೞ۰ݶ ѾҴ schema ৻ স ਃ
GraphQL Lighthouse-php with EloquentORM Example 1. Type type User
{ id: ID! email: String! type: Int! } Eloquent ORM ݽ؛җ ڙэ ࢿ
GraphQL Lighthouse-php with EloquentORM 2. Read type Query { user(id:
ID! @eq) : User! @find } 2-1. ױੌ ઑഥ => select * from user where id = :id limit 1 Example
GraphQL Lighthouse-php with EloquentORM type Query { user(id: ID! @eq)
: User! @find } ઑѤਸ ೲਊೡ ஸۢҗ ఋੑ where ‘=’ ߈ജ ఋੑ ->first()
GraphQL Lighthouse-php with EloquentORM 2. Read type Query { user(type:
Int! @eq) : [User!]! @all } 2-2. ܻझ ઑഥ => select * from user where type = :type Example
GraphQL Lighthouse-php with EloquentORM ߈ജ ఋੑ ( ߓৌ )
type Query { user(type: Int! @eq) : [User!]! @all } ->get() ઑѤਸ ೲਊೡ ஸۢҗ ఋੑ where ‘=’
GraphQL Lighthouse-php with EloquentORM 2. Read type Query { user(type:
Int! @eq) : [User!]! @pagination } 2-2. ܻझ ઑഥ (ಕ֎࣌) => select * from user where type = :type offset :offset limit :limit Example
GraphQL Lighthouse-php with EloquentORM 3. Middleware type Query { user(type:
Int! @eq) : [User!]! @pagination @middleware(checks: ["auth:api"]) } Example
GraphQL Lighthouse-php with EloquentORM 4. Muatation type Muatation { createUser(
email: String! pw: String! ) : User! @create } @create, @update, @delete, @upsert(updateOrCreate) Example
GraphQL Lighthouse-php with EloquentORM 5. Eloquent Relationships Example type Post
{ id: ID! email: String! type: Int! Author: User! @belongsTo(relation: “user”) } class User extends Model { …… public function user() { return $this->belongsTo(User::class) } } => Model ҙ҅৬ ܴਸ ڙэ যષ @hasOne, @hasMany, @belongsToMany, @belongsTo
GraphQL Lighthouse-php with EloquentORM query { post(no : 1) {
no title user { email } } } { "data": { "post": { "no": “1", "title": “test", "user": { “email": "5" } } } } =>
GraphQL Lighthouse-php with EloquentORM 6. Event Example type Muatation {
createUser( email: String! pw: String! ) : User! @create @event(dispatch: "App\\Events\ \CreateUserEvent") } Event direction ਸ ాೞৈ query / mutation റ ݫੌ ࣠ ١ ৈ۞ ೯زٜਸ ೡ ࣻ ѱ ࢸ ೡ ࣻ laravel events class
GraphQL Lighthouse-php with EloquentORM ৻ীب ৈ۞о directiveٜਸ ઑೞৈ ௪ܻ оמ
GraphQL ੋ۽झಖ࣌ RestAPI ীࢲח API ݺࣁࢲо ਃ GraphQL ੋ۽झಖ࣌ਵ۽
೧Ѿ
GraphQL नӏ दझమী ਊ Ѿҗ ੌ যٚ!
GraphQL नӏ दझమী ਊ Ѿҗ ਗې flow controller / service
/ repository => route ١۾ => response ҳઑ ҕਬ(ޙࢲ) => ೖ٘ߔ => ޖೠ ߈ࠂ ՙীীীীু!
GraphQL नӏ दझమী ਊ Ѿҗ ߸҃ flow झః݃ ࢿ =>
! PROFIT!