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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
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
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
920
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.3k
テーブルをDELETEした
yuzneri
0
130
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.5k
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
450
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
130
광주소프트웨어마이스터고등학교 DevFest 특강 - 바이브 코딩 시대에서 주니어 개발자로 살아남는 방법
utilforever
1
160
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
200
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
880
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
110
Foundation Models frameworkで画像分析
ryodeveloper
1
210
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
230
Featured
See All Featured
A designer walks into a library…
pauljervisheath
211
24k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
380
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
450
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Evolving SEO for Evolving Search Engines
ryanjones
0
250
Automating Front-end Workflow
addyosmani
1370
210k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
470
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
470
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
30 Presentation Tips
portentint
PRO
1
360
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
200
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
280
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