Node 学園祭2018のトークで使用したスライドです。 https://nodefest.jp/2018/schedule.html#conference-5-8
GraphQL + Apollo により変化するGraphQL + Apollo により変化するクライアントアプリ設計クライアントアプリ設計Frontend engineer@vwxyuratoooo
View Slide
About MeAbout MeYutaro Miyazaki(@vwxyutarooo)Frontend engineerWork for MercariReact, GraphQL, Apollo
Before I start to talk
GraphQL, Apollo and MeGraphQL, Apollo and MeMercari Web Re Architecture
GraphQL, Apollo and MeGraphQL, Apollo and MeTypeScript, GraphQL, Apollo, Next.js React
GraphQL Summit 2018GraphQL Summit 2018
What I going to talk about...What I going to talk about...
AgendaAgendaPreparationWhat the GraphQL isWhat the Apollo isApollo ClientReact ApolloApollo Link StateCompare with Flux
What the GraphQL isWhat the GraphQL isGraphQL is an open‒source data queryand manipulation language.
Available for several languagesJavaScript, Go, Kotlin, Ruby, etcReplacement of Restful API?As a BFFAggregate Microservices
What the Apollo isWhat the Apollo is
Apollo PlatformApollo Platform
VSCodeVSCodeApollo Engine + VSCodehttps://summit‒2018‒apollo‒client.netlify.com/#27
Apollo ClientApollo ClientApollo BoostApollo LinkApollo Cache
import ApolloClient from "apollo-boost";const client = new ApolloClient({uri: 'https://graphql-server.com'});import ApolloClient from "apollo-boost";import gql from "graphql-tag";const client = new ApolloClient({uri: 'https://graphql-server.com'});client.query({query: gql`{rates(currency: "USD") {currency}}`}).then(result => console.log(result));
React ApolloReact Apolloimport React from "react";import { render } from "react-dom";import { ApolloProvider } from "react-apollo";const App = () => (My first Apollo app );render(, document.getElementById("root"));
Define SchemaPass schema to Query Component as propsconst GET_DOGS = gql`{dogs {idbreed}}`;import { Query } from 'react-apollo';const Feed = () => ({({ loading, error, data }) => {if (error) return ;if (loading || !data) return ;return ;}});
Mutationconst ADD_TODO = gql`mutation AddTodo($type: String!) {addTodo(type: $type) {idtype}}`;const AddTodo = ({ value }) => {return ({(addTodo) => (type="button"onClick={() => addTodo({ variables: { type: value } })}>Add Todo)});};
Apollo Link StateApollo Link StateSchema for local stateAll of state management to be declarativeControlled under the Apollo Cache
In ConclusionIn ConclusionFocus to the presentation logic, UI thing.
ありがとうございました