Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL - JavaScript Fullstack Solution

Michael Hsu
December 29, 2017

GraphQL - JavaScript Fullstack Solution

Michael Hsu

December 29, 2017
Tweet

More Decks by Michael Hsu

Other Decks in Programming

Transcript

  1. TODOMVC - FULLSTACK . (lerna) !"" packages #"" constants #

    Shared constants between client and server. #"" server # GraphQL Server !"" web # Web server
  2. HOW TO BUILD A GRAPHQL SERVER? (1/3) GRAPHQL OPERATION ▸

    Query: R ▸ Mutation: CUD ▸ Subscription: Realtime (WS, MQTT) ▸ https://todomvc-server.now.sh/
  3. HOW TO BUILD A GRAPHQL SERVER? (2/3) LIBRARIES ‣ 1.

    graphql-yoga: express, graphql-tools, graphql- subscriptions, graphiql ‣ 2. knex.js: ORM ‣ 3. Pkg: Binary compiler ‣ 4. Docker: Container
  4. HOW TO BUILD A GRAPHQL SERVER? (3/3) MODULE ▸ 1.

    connector: connect to database ▸ 2. models: ORM, database manipulate ▸ 3. typeDefs: GraphQL type ▸ 4. resolver: Logic ▸ https://github.com/evenchange4/todomvc-subscriptions/ blob/master/packages/server/README.md
  5. WEB

  6. HOW TO BUILD A GRAPHQL WEB? (1/2) LIBRARIES ▸ 1.

    Next.js: Server-rendered React applications ▸ 2. Apollo-client: GraphQL client ▸ 3. Apollo-link-state: Manage local state (redux)
  7. HOW TO BUILD A GRAPHQL WEB? (2/2) MODULE ▸ 1.

    gql: GraphQL type ▸ 2. hoc: React ▸ 3. resolvers: GraphQL for local state (getState, reducer) ▸ https://github.com/evenchange4/todomvc-subscriptions/ blob/master/packages/web/README.md
  8. SERVER & WEB CONCLUSION - SIZE ▸ Server: Linux binary

    64MB ▸ Web: bundle size 433KB + 101KB (Code split)