Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Implementing GraphQL with Laravel and Vue.js
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Alefe Souza
August 27, 2019
Programming
370
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
540
Implementing GraphQL with PHP
alefesouza
0
610
Node.js Chatbots with Bot Framework
alefesouza
0
420
GraphQL: A new way to write APIs
alefesouza
0
460
Firebase as back-end
alefesouza
0
500
GitLab: A tool for the entire DevOps lifecycle.pdf
alefesouza
0
730
Web Components with Vanilla.js
alefesouza
0
690
Other Decks in Programming
See All in Programming
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
970
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
3
1.4k
新卒PdEのリアル
ryu1013
1
440
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
480
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
110
信頼性の目標を誰も求めてない
shubox
0
500
業務時間外もAIに働いてもらう話
colorful12
3
10k
Webの地図
yosuke_furukawa
PRO
3
2.4k
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
270
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
55
36k
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.6k
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
500
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Side Projects
sachag
455
43k
ラッコキーワード サービス紹介資料
rakko
1
4.8M
Abbi's Birthday
coloredviolet
3
9.8k
The SEO Collaboration Effect
kristinabergwall1
1
550
Code Reviewing Like a Champion
maltzj
528
40k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
310
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Marketing to machines
jonoalderson
1
5.8k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
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