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
React Finland – React & GraphQL – From zero to ...
Search
Glenn Reyes
April 24, 2019
Programming
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
React Finland – React & GraphQL – From zero to production
Glenn Reyes
April 24, 2019
More Decks by Glenn Reyes
See All by Glenn Reyes
Dutch AI Conference - Building Interactive Chat Interfaces with MCP-UI
glennreyes
0
36
Advanced TypeScript for React
glennreyes
0
130
TypeScript Patterns for Better React Components
glennreyes
1
540
GraphQL for React Developers
glennreyes
0
230
When things go wrong, get errors right!
glennreyes
0
150
GraphQL for JS developers
glennreyes
1
180
Building Dapps with React
glennreyes
0
130
Third-Party or Custom Code? The Art of Software Decisions
glennreyes
0
110
UI/UX challenges of Web3 and Dapps
glennreyes
0
200
Other Decks in Programming
See All in Programming
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
810
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
150
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
230
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
310
源内ハンズオン概要編
hideg
0
160
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
130
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
110
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
200
Google Apps Script で Ruby を動かす
kawahara
0
150
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
130
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
110
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
630
A Modern Web Designer's Workflow
chriscoyier
698
190k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
480
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
First, design no harm
axbom
PRO
2
1.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Code Review Best Practice
trishagee
74
20k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
240
It's Worth the Effort
3n
188
29k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
Transcript
@glnnrys React & GraphQL From zero to production @glnnrys
@glnnrys > whoami
@glnnrys query getCoach { name twitter job expertise oss(type: "most-popular")
elseIDo } { "data": { "name": "Glenn Reyes", "twitter": "@glnnrys", "job": "Freelance Front-end Engineer", "expertise": ["React", "GraphQL"], "oss": ["graphpack", "react-countup"], "elseIDo": [ "Co-organize React Vienna", "Speak at conferences", "Give workshops" ] } } @glnnrys
@glnnrys Goals for today
@glnnrys
@glnnrys Learn
@glnnrys Fun
@glnnrys Ship
@glnnrys What is GraphQL?
@glnnrys
@glnnrys Query Language for APIs
@glnnrys
@glnnrys Describe your schema in a type system
@glnnrys type Speaker { id: ID! name: String talks: [Talk]!
} type Talk { id: ID! title: String by: Speaker }
@glnnrys It's language agnostic
@glnnrys
@glnnrys Query IDEs
@glnnrys github.com/graphql/graphiql
@glnnrys github.com/prisma/graphql-playground
@glnnrys Automatic documentation
@glnnrys
@glnnrys
@glnnrys
@glnnrys <Query query={gql` query getUser($id: ID!) { user(id: $id) {
id name bio twitter } } `} variables={{ id: props.id }} > {({ data, error, loading }) => { if (loading) return 'Loading ...'; if (error) return `Something went wrong! ${error.message}`; return <Profile data={data.user} />; }} </Query>
@glnnrys Questions?
@glnnrys Let's get started!
@glnnrys github.com/glennreyes/react-graphql-workshop
@glnnrys Schemas & Types
@glnnrys type Person { id: ID! # Not nullable name:
String # Nullable age: Int weight: Float isOnline: Boolean posts: [Post!]! # Not nullable (but empty list is fine) } type Post { id: ID! slug: String! text: String! } type Query { allPersons: [Person!]! personById(id: ID!): Person allPosts: [Post!]! postBySlug(slug: String!): Post } type Mutation { createPost(from: Person!, slug: String!, text: String!): Post! }
@glnnrys Resolver
@glnnrys (obj, args, context, info) => result;
@glnnrys const resolvers = { Query: { personById: (obj, args)
=> API.getPersonById(args.id), }, Person: { posts: obj => API.getPostsByPersonId(obj.id), // All other fields are resolved by default }, };
@glnnrys Apollo Client
@glnnrys import ApolloClient from 'apollo-boost'; import { ApolloProvider } from
'react-apollo'; const client = new ApolloClient({ uri: '[MY_GRAPHQL_ENDPOINT]', headers: { // ... }, }); <ApolloProvider client={client}> <App /> </ApolloProvider>;
@glnnrys Query
@glnnrys import gql from 'graphql-tag'; import { Query } from
'react-apollo'; <Query query={myQuery}> {({ data, loading, error }) => { // ... }} </Query>;
@glnnrys Mutation
@glnnrys import gql from 'graphql-tag'; import { Mutation } from
'react-apollo'; <Mutation mutation={myMutation} variables={{}} onCompleted={data => {}} refetchQueries={[{ query: queryToRefetch, variables: {} }]} awaitRefetchQueries > {mutate => ( // ... )} </Mutation>;
@glnnrys Feedback
@glnnrys Thank you!