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
Implementing GraphQL with Laravel and Vue.js
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Alefe Souza
August 27, 2019
Programming
360
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Implementing GraphQL with Laravel and Vue.js
https://github.com/alefesouza/talk-laravel-vue-graphql
Alefe Souza
August 27, 2019
More Decks by Alefe Souza
See All by Alefe Souza
NativeScript: Native Apps with Angular
alefesouza
0
500
Implementing GraphQL with PHP - PHP Community Summit
alefesouza
0
330
React: Zero to Hero
alefesouza
2
530
Implementing GraphQL with PHP
alefesouza
0
600
Node.js Chatbots with Bot Framework
alefesouza
0
420
GraphQL: A new way to write APIs
alefesouza
0
450
Firebase as back-end
alefesouza
0
490
GitLab: A tool for the entire DevOps lifecycle.pdf
alefesouza
0
720
Web Components with Vanilla.js
alefesouza
0
690
Other Decks in Programming
See All in Programming
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
210
テーブルをDELETEした
yuzneri
0
130
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
790
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
0
120
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
130
霧の中の代数的エフェクト
funnyycat
1
450
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
230
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
280
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
130
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
480
React本体のコードリーディング
high_g_engineer
0
120
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
160
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
310
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Skip the Path - Find Your Career Trail
mkilby
1
170
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Automating Front-end Workflow
addyosmani
1370
210k
Chasing Engaging Ingredients in Design
codingconduct
0
250
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Code Review Best Practice
trishagee
74
20k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
400
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Exploring anti-patterns in Rails
aemeredith
3
450
Transcript
Implementando GraphQL com Laravel e Vue.js
@alefesouza https://as.dev Alefe Souza Full Stack Developer @alefesouza Programador PHP
desde os 17 anos, instrutor de desenvolvimento de software, formado em análise e desenvolvimento de sistemas, Microsoft Specialist em tecnologias web.
GraphQL? Uma especificação de linguagem de consulta de APIs, desenvolvida
pelo Facebook. @alefesouza https://as.dev
@alefesouza https://as.dev Príncipios • Tipos • Queries • Mutations
Tipos Permitem especificar objetos de entrada e saída, impedindo a
requisição caso ocorra algo fora do padrão. @alefesouza https://as.dev
Queries Utilizadas para consultas no endpoint único, também é muito
fácil de solicitar apenas o que os campos necessários. @alefesouza https://as.dev
Mutations Utilizadas para realizar qualquer tipo de alteração nos dados,
equivalente ao POST, PUT, PATCH, DELETE, identificados pelo nome. @alefesouza https://as.dev
Onde funciona? @alefesouza https://as.dev
Onde funciona? @alefesouza https://as.dev
Implementação com Laravel @alefesouza https://as.dev $ composer install rebing/graphql-laravel $
php artisan vendor:publish --provider="Rebing\GraphQL\GraphQLServiceProvider"
Implementação no Vue.js @alefesouza https://as.dev $ npm install --save vue-apollo
graphql apollo-boost
Implementação no Vue.js @alefesouza https://as.dev import VueApollo from 'vue-apollo'; import
ApolloClient from 'apollo-boost'; import App from './App.vue'; Vue.use(VueApollo); const apolloClient = new ApolloClient(); const apolloProvider = new VueApollo({ defaultClient: apolloClient, }); new Vue({ el: '#app', apolloProvider, render: h => h(App), });
@alefesouza https://as.dev <ApolloQuery :query="require('./../gralphql/queries/fetchUsers.gql')" > <template v-slot="{ result: { loading,
error, data } }"> <!-- Loading --> <div v-if="loading" class="loading apollo">Carregando...</div> <!-- Error --> <div v-else-if="error" class="error apollo">Houve um erro</div> <!-- Result --> <div v-else-if="data" class="result apollo"> <ul> <li v-for="user in data.users" :key="user.id"> <b>Nome:</b> {{ user.name }}<br> <b>E-mail:</b> {{ user.email }}<br> <b>Empresa:</b> {{ user.company.name }} </li> </ul> </div> </template> </ApolloQuery>
@alefesouza https://as.dev <ApolloQuery :query="require('./../gralphql/queries/fetchUser.gql')" :variables="{ id: userId }" > <template
v-slot="{ result: { loading, error, data } }"> <!-- Loading --> <div v-if="loading" class="loading apollo">Carregando...</div> <!-- Error --> <div v-else-if="error" class="error apollo">Houve um erro</div> <!-- Result --> <div v-else-if="data" class="result apollo"> <b>Nome:</b> {{ data.user.name }}<br> <b>E-mail:</b> {{ data.user.email }}<br> <b>Empresa:</b> {{ data.user.company.name }} </div> </template> </ApolloQuery>
@alefesouza https://as.dev <ApolloMutation :mutation="require('../gralphql/mutations/addUser.gql')" :variables="{ input }" @done="onDone" > <template
v-slot="{ mutate, loading, error }"> <div> <div> <div>Nome:</div> <input type="text" v-model="input.name"> </div> <div> <div>E-mail:</div> <input type="text" v-model="input.email"> </div> <div> <div>ID da empresa:</div> <input type="number" v-model="input.company_id"> </div> </div> <button :disabled="loading" @click="mutate()">Salvar</button> <p v-if="error">Ocorreu um erro: {{ error }}</p> </template> </ApolloMutation>
Live Code! http://bit.ly/talk-laravel-vue-graphql @alefesouza https://as.dev
Obrigado!! @alefesouza https://as.dev http://bit.ly/talk-laravel-vue-graphql