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 PHP - PHP Community S...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Alefe Souza
September 27, 2019
Programming
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Implementing GraphQL with PHP - PHP Community Summit
Alefe Souza
September 27, 2019
More Decks by Alefe Souza
See All by Alefe Souza
NativeScript: Native Apps with Angular
alefesouza
0
500
Implementing GraphQL with Laravel and Vue.js
alefesouza
0
360
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
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
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
140
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
210
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
560
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
940
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.9k
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7k
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
360
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
350
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
170
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
220
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
350
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
250
Utilizing Notion as your number one productivity tool
mfonobong
4
550
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
370
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Building the Perfect Custom Keyboard
takai
2
850
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
A Tale of Four Properties
chriscoyier
163
24k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
500
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
170
sira's awesome portfolio website redesign presentation
elsirapls
0
340
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
380
Transcript
Implementando GraphQL com PHP @alefesouza https://as.dev
Alefe Souza @alefesouza https://as.dev 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.
Agenda • O que é GraphQL • Conceitos básicos •
Demo • Implementação em Laravel • Implementação no front-end @alefesouza https://as.dev
@alefesouza https://as.dev GraphQL? Uma especificação de linguagem de consulta de
APIs, desenvolvida pelo Facebook.
@alefesouza https://as.dev GraphQL? Baseado em apenas um endpoint.
@alefesouza https://as.dev GraphQL? Fortemente tipada.
@alefesouza https://as.dev GraphQL? Documentação automática.
@alefesouza https://as.dev Conceitos básicos • Tipos • Queries • Mutations
@alefesouza https://as.dev 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 Quem utiliza?
@alefesouza https://as.dev $ composer install webonyx/graphql-php Como iniciar?
@alefesouza https://as.dev Demo! http://bit.ly/talk-graphql-php
@alefesouza https://as.dev Implementação no Laravel $ composer install rebing/graphql-laravel $
php artisan vendor:publish --provider="Rebing\GraphQL\GraphQLServiceProvider"
@alefesouza https://as.dev Implementação no front-end $ npm install --save vue-apollo
graphql apollo-boost
@alefesouza https://as.dev Implementação no front-end 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('./../graphql/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('./../graphql/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('../graphql/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>
@alefesouza https://as.dev Obrigado! @alefesouza https://bit.ly/talk-graphql-php https://bit.ly/talk-laravel-vue-graphql