$30 off During Our Annual Pro Sale. View Details »

React Architecture at Product Hunt

Radoslav Stankov
September 12, 2020
760

React Architecture at Product Hunt

What is the architecture at our latest product YourStack.

Radoslav Stankov

September 12, 2020
Tweet

Transcript

  1. Product Hunt
    React Architecture
    Radoslav Stankov 15/09/2020

    View Slide

  2. !

    View Slide

  3. Radoslav Stankov
    @rstankov
    blog.rstankov.com

    twitter.com/rstankov

    github.com/rstankov

    speakerdeck.com/rstankov

    View Slide

  4. View Slide

  5. View Slide

  6. Architecture

    View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. " Frontend Tech Stack

    View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. # Have good defaults
    $ Have good code organization
    % Make common operations easy
    & Isolate dependencies
    ' Extensibility and reusability

    View Slide

  19. # Have good defaults
    $ Have good code organization
    % Make common operations easy
    & Isolate dependencies
    ' Extensibility and reusability

    View Slide

  20. View Slide

  21. View Slide

  22. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  23. 2
    1 3
    Support Components Pages

    View Slide

  24. Support
    Components
    Pages

    View Slide

  25. 1) Support 2) Components 3) Pages

    View Slide

  26. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  27. 1 Support
    components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  28. 1 Support
    Components
    2
    components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  29. 1 Support
    Components
    Pages
    2
    3
    components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  30. 1
    Support

    View Slide

  31. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  32. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  33. import getNextConfig from 'next/config';
    const config = getNextConfig() as any;
    // ... other configuration
    export const environment = {
    isTest: config.publicRuntimeConfig.NODE_ENV === 'test',
    isProduction: config.publicRuntimeConfig.NODE_ENV ===
    'production',
    isBrowser: !!process.browser,
    };
    config.ts

    View Slide

  34. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  35. apollo client:codegen \
    --localSchemaFile="graphql/schema.json" \
    --addTypename \
    --tagName=gql \
    --target=typescript \
    --includes="{components,routes,utils,hooks,layouts}/**/*.{tsx,ts}" \
    --outputFlat="graphql/types.ts"

    View Slide

  36. View Slide

  37. components/Profile/Avatar/Fragment.ts
    import gql from 'graphql-tag';
    export default gql`
    fragment ProfileAvatarFragment on Profile {
    id
    name
    kind
    imageUrl
    }
    `;

    View Slide

  38. // ====================================================
    // GraphQL fragment: ProfileAvatarFragment
    // ====================================================
    export interface ProfileAvatarFragment {
    __typename: "Profile";
    id: string;
    name: string;
    kind: string;
    imageUrl: string | null;
    }
    graphql/types.ts

    View Slide

  39. import { ProfileAvatarFragment } from '~/graphql/types';

    View Slide

  40. View Slide

  41. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  42. View Slide

  43. useKey()
    useIsMounted()
    useTimeout()


    useHideOnTop()

    View Slide

  44. useGraphQLFragment()
    useViewier()
    useIsLoggedIn()

    View Slide

  45. useGraphQLFragment()
    useViewier()
    useIsLoggedIn()

    View Slide

  46. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  47. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  48. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  49. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  50. View Slide

  51. import formatCount from './formatCount';
    describe(formatCount.name, () => {
    it('does proper pluralization', () => {
    expect(formatCount(0, 'item')).toEqual('0 items');
    expect(formatCount(1, 'item')).toEqual('1 item');
    expect(formatCount(10, 'items')).toEqual('10 items');
    });
    it('formats 1000-9999 as Ks', () => {
    expect(formatCount(1000)).toEqual('1K');
    expect(formatCount(1500)).toEqual('1.5K');
    });
    // ....
    });
    utils/formatCount.test.ts

    View Slide

  52. import { format } from 'date-fns';
    export function formatDateTime(date: string) {
    return format(date, 'H:mm A · MMM D, YYYY');
    }
    utils/date.ts

    View Slide

  53. moment date.ts Component Page

    View Slide

  54. date.ts Component Page
    date-fns

    View Slide

  55. utils/
    external/
    Intercom/
    OneSignal/
    Segment/
    Sentry/

    View Slide

  56. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  57. 2
    Components

    View Slide

  58. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  59. View Slide

  60. View Slide

  61. ( Component as directory
    components/
    Component/
    SubComponent/
    Fragment.graphql
    Mutation.graphql
    icon.svg
    index.js
    styles.css
    utils.js

    View Slide

  62. View Slide

  63. import * as React from "react";
    import Font from "components/Font";
    {text}

    View Slide

  64. import * as React from "react";
    import styles from "./styles.css";
    export function Text({ children }) {
    return (

    {children}

    );
    }
    components/Font/index.tsx

    View Slide

  65. CSS
    // style.css
    .text {
    font-size: 14px;
    }
    CSS
    // component.js

    import styles from './styles.css';


    CSS
    // style.css
    .text_3mRwv {
    font-size: 14px;
    }
    CSS
    // result.js


    View Slide

  66. import * as React from "react";
    import Font from "components/Font";
    text
    // -> text

    View Slide

  67. import * as React from "react";
    import Font from "components/Font";
    text
    // -> text
    text
    // -> text

    View Slide

  68. import * as React from "react";
    import Font from "components/Font";
    text
    // -> text
    text
    // -> text
    text
    Font.Text>
    // -> text

    View Slide

  69. import * as React from "react";
    import Font from "components/Font";
    text
    // -> text
    text
    // -> text
    text
    Font.Text>
    // -> text
    ( Pass custom component as prop

    View Slide

  70. import * as React from "react";
    import styles from "./styles.css";
    export function Text({ component,
    children, ...props }) {
    Component = component || "span";

    return (
    {...props}>
    {children}

    );
    }
    ( Pass custom component as prop

    View Slide

  71. import * as React from "react";
    import styles from "./styles.css";
    export function Text({ component, children, ...props }) {
    Component = component || "span";

    return (

    {children}

    );
    }
    )
    ( Pass custom component as prop

    View Slide

  72. import * as React from "react";
    import styles from "./styles.css";
    export function Text({ component, ...props }) {
    Component = component || "span";
    return ;
    }
    *
    ( Pass custom component as prop

    View Slide

  73. import * as React from "react";
    import Font from "components/Font";
    text
    // -> Text

    View Slide

  74. import * as React from "react";
    import Font from "components/Font";
    import styles from "./styles.css";
    text
    // -> text

    View Slide

  75. import * as React from "react";
    import Font from "components/Font";
    import styles from "./styles.css";
    text
    // -> text
    ( Pass extra class name

    View Slide

  76. import * as React from "react";
    import styles from "./styles.css";
    import classNames from "classnames";
    export function Text({ component, className, ...props }) {
    Component = component || "span";

    return }
    ( Pass extra class name

    View Slide

  77. yarn install "classnames"

    View Slide

  78. View Slide

  79. View Slide










  80. View Slide

  81. Input

    View Slide

  82. Input Loading

    View Slide

  83. Input Loading
    Success

    View Slide

  84. Input Loading
    Success
    Errors

    View Slide

  85. Submit Server
    Success
    Errors

    View Slide

  86. remoteCall Server
    { result: 'ok' }
    { errors: {…} }

    View Slide

  87. remoteCall Server
    { result: 'ok' }
    { 

    errors: {
    field1: 'error1',

    field2: 'error2'

    }

    }

    View Slide

  88. { 

    errors: {
    field1: 'error1',

    field2: 'error2'

    }

    }

    View Slide

  89. { 

    errors: {
    field1: 'error1',

    field2: 'error2'

    }

    }

    View Slide

  90. mutation UserSettingsUpdate($input: UserSettingsUpdateInp
    response: userSettingsUpdate(input: $input) {
    node {
    id
    ...MySettingsPageViewer
    }
    errors {
    field
    message
    }
    }
    }

    View Slide

  91. mutation UserSettingsUpdate($input: UserSettingsUpdateInp
    response: userSettingsUpdate(input: $input) {
    node {
    id
    ...MySettingsPageViewer
    }
    errors {
    field
    message
    }
    }
    }

    View Slide










  92. View Slide

  93. View Slide

  94. import { TopicSearch_Topic as ITopic } from '~/graphql/types';
    import ItemList from './ItemList'
    import QUERY from './Query';
    import SearchResultItem from './SearchResultItem'
    import { IFormArrayFields } from '~/components/Form/types';
    import { useLoadTopicsIds } from './utils';
    interface IProps {
    fields: IFormArrayFields;
    }
    export default function TopicsInput({ fields }: IProps) {
    const addTopic = (topic: ITopic) => {
    fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);

    View Slide

  95. import { TopicSearch_Topic as ITopic } from '~/graphql/types';
    import ItemList from './ItemList'
    import QUERY from './Query';
    import SearchResultItem from './SearchResultItem'
    import { IFormArrayFields } from '~/components/Form/types';
    import { useLoadTopicsIds } from './utils';
    interface IProps {
    fields: IFormArrayFields;
    }
    export default function TopicsInput({ fields }: IProps) {
    const addTopic = (topic: ITopic) => {
    fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);

    View Slide

  96. import { TopicSearch_Topic as ITopic } from '~/graphql/types';
    import ItemList from './ItemList'
    import QUERY from './Query';
    import SearchResultItem from './SearchResultItem'
    import { IFormArrayFields } from '~/components/Form/types';
    import { useLoadTopicsIds } from './utils';
    interface IProps {
    fields: IFormArrayFields;
    }
    export default function TopicsInput({ fields }: IProps) {
    const addTopic = (topic: ITopic) => {
    fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);

    View Slide

  97. import { TopicSearch_Topic as ITopic } from '~/graphql/types';
    import ItemList from './ItemList'
    import QUERY from './Query';
    import SearchResultItem from './SearchResultItem'
    import { IFormArrayFields } from '~/components/Form/types';
    import { useLoadTopicsIds } from './utils';
    interface IProps {
    fields: IFormArrayFields;
    }
    export default function TopicsInput({ fields }: IProps) {
    const addTopic = (topic: ITopic) => {
    fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);

    View Slide

  98. import { TopicSearch_Topic as ITopic } from '~/graphql/types';
    import ItemList from './ItemList'
    import QUERY from './Query';
    import SearchResultItem from './SearchResultItem'
    import { IFormArrayFields } from '~/components/Form/types';
    import { useLoadTopicsIds } from './utils';
    interface IProps {
    fields: IFormArrayFields;
    }
    export default function TopicsInput({ fields }: IProps) {
    const addTopic = (topic: ITopic) => {
    fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);

    View Slide

  99. import { TopicSearch_Topic as ITopic } from '~/graphql/types';
    import ItemList from './ItemList'
    import QUERY from './Query';
    import SearchResultItem from './SearchResultItem'
    import { IFormArrayFields } from '~/components/Form/types';
    import { useLoadTopicsIds } from './utils';
    interface IProps {
    fields: IFormArrayFields;
    }
    export default function TopicsInput({ fields }: IProps) {
    const addTopic = (topic: ITopic) => {
    fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);

    View Slide

  100. fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);
    if (topics === null) {
    return null;
    }
    return (

    itemsPath="topics"
    onSelect={addTopic}
    query={QUERY}
    renderItem={SearchResultItem} />


    );
    }

    View Slide

  101. fields.value.includes(topic.id) && fields.push(topic.id);
    }
    const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);
    if (topics === null) {
    return null;
    }
    return (

    itemsPath="topics"
    onSelect={addTopic}
    query={QUERY}
    renderItem={SearchResultItem} />


    );
    }

    View Slide

  102. const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);
    if (topics === null) {
    return null;
    }
    return (

    itemsPath="topics"
    onSelect={addTopic}
    query={QUERY}
    renderItem={SearchResultItem} />


    );
    }
    ProductsInput.isArray = true;

    View Slide

  103. const removeTopic = (topic: ITopic) => {
    fields.remove(fields.value.indexOf(topic.id));
    }
    const topics = useLoadTopicsIds(fields);
    if (topics === null) {
    return null;
    }
    return (

    itemsPath="topics"
    onSelect={addTopic}
    query={QUERY}
    renderItem={SearchResultItem} />


    );
    }
    ProductsInput.isArray = true;

    View Slide

  104. View Slide

  105. Which is the form
    library we are
    using?!

    View Slide

  106. View Slide

  107. View Slide

  108. +

    View Slide

  109. +

    View Slide

  110. +

    View Slide

  111. , unified styles
    - common interface
    . custom inputs
    / understand backend
    GraphQL
    0 Form

    View Slide

  112. View Slide

  113. href={paths.profile(profile)} />

    View Slide

  114. href={paths.profile(profile)} />
    onClick={onClickReturnsPromise}
    loadingText="Waiting for promise to resolve" />

    View Slide

  115. href={paths.profile(profile)} />
    onClick={onClickReturnsPromise}
    loadingText="Waiting for promise to resolve" />
    confirm="Are you sure?"
    mutation={DELETE_MUTATION}
    input={{ id }}
    loadingText="Deleting..."
    onMutate={redirectSomeWhere} />

    View Slide

  116. href={paths.profile(profile)} />
    onClick={onClickReturnsPromise}
    loadingText="Waiting for promise to resolve" />
    confirm="Are you sure?"
    mutation={DELETE_MUTATION}
    input={{ id }}
    loadingText="Deleting..."
    onMutate={redirectSomeWhere} />

    View Slide






  117. View Slide

  118. Utility
    Styling
    Domain

    View Slide

  119. View Slide

  120. View Slide

  121. LikeButton Button

    View Slide

  122. Domain Component

    View Slide

  123. AnswerCard Like Button

    View Slide



  124. thumbnail={name={answer.profile.name}
    subtitle="recommendations for" />
    {answer.question.title}

    {answer.products.map((product) => (
    url={paths.profile.show(product)}
    thumbnail={name={product.name} />
    ))}





    Domain Component

    View Slide

  125. Domain Component











    View Slide

  126. Atomic Design

    View Slide

  127. ...Kinda 1

    View Slide

  128. 2 generic components
    . domain components

    View Slide

  129. 3
    Pages

    View Slide

  130. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  131. export default {
    root: () => '/',
    static: {
    about() => '/about',
    // ...
    }
    profiles: {
    people: () => '/people',
    show: ({ slug }: { slug: string }) => `/@${slug}`,
    // ...
    },
    // ...
    };
    path.ts

    View Slide

  132. import paths from 'ph/paths';

    paths.root(); // => /
    paths.static.about(); // => /about/
    paths.profiles.people(); // => /people
    paths.profiles.show(profile); // => /@rstankov

    View Slide

  133. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  134. View Slide

  135. View Slide

  136. View Slide




  137. {children}




    layouts/Main/index.tsx

    View Slide

  138. View Slide





  139. {content}


    layouts/Main/index.tsx

    View Slide

  140. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  141. )
    components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  142. View Slide

  143. pages/profiles/[slug]/index.ts

    View Slide

  144. import page from '~/routes/profiles/show';
    export default page;
    pages/profiles/[slug]/index.ts

    View Slide

  145. import page from '~/routes/profiles/show';
    export default page;
    pages/profiles/[slug]/index.ts
    3

    View Slide

  146. components/
    graphql/
    hooks/
    layouts/
    pages/
    routes/
    server/
    static/
    styles/
    types/
    utils/
    config.ts
    paths.ts

    View Slide

  147. Component as directory
    routing/
    profiles/
    show/
    SubComponent1/
    SubComponent2/
    Query.graphql
    index.js
    styles.css
    utils.js

    View Slide

  148. Loading State
    Page Life Cycle

    View Slide

  149. Loading State
    Page Life Cycle

    View Slide

  150. Loading State
    Error State
    Page Life Cycle

    View Slide

  151. Loading State
    Not Found Error
    Server Error
    Authorization
    Error
    Authentication
    Error
    Error State
    Page Life Cycle

    View Slide

  152. Loading State
    Not Found Error
    Server Error
    Authorization
    Error
    Authentication
    Error
    Error State
    Loaded State
    Page Life Cycle

    View Slide

  153. Loading State
    Not Found Error
    Server Error
    Authorization
    Error
    Authentication
    Error
    SEO
    Error State
    Analytics
    Loaded State
    Page Life Cycle
    ???

    View Slide

  154. Loading State
    Not Found Error
    Server Error
    Authorization
    Error
    Authentication
    Error
    SEO
    Error State
    Analytics
    Loaded State
    render
    Page Life Cycle
    ???

    View Slide

  155. import createPage from '~/utils/createPage';
    import ProfileLayout from '~/layouts/Profile';
    import { ProfileShowPage } from '~/graphql/types';
    import QUERY from './Query';
    export default createPage({
    query: QUERY,
    queryVariables: ({ slug }) => ({ slug }),
    requireLogin: true,
    requirePermissions: ({ profile }) => profile.canManage,
    requireFeature: 'feature_flag',
    tags: ({ profile }) => profile.seoTags,
    title: ({ profile }) => profile.name,
    component: ({ data: { profile } }) => (
    {...}
    ),
    });

    View Slide

  156. import createPage from '~/utils/createPage';
    import ProfileLayout from '~/layouts/Profile';
    import { ProfileShowPage } from '~/graphql/types';
    import QUERY from './Query';
    export default createPage({
    query: QUERY,
    queryVariables: ({ slug }) => ({ slug }),
    requireLogin: true,
    requirePermissions: ({ profile }) => profile.canManage,
    requireFeature: 'feature_flag',
    tags: ({ profile }) => profile.seoTags,
    title: ({ profile }) => profile.name,
    component: ({ data: { profile } }) => (
    {...}
    ),
    });

    View Slide

  157. import createPage from '~/utils/createPage';
    import ProfileLayout from '~/layouts/Profile';
    import { ProfileShowPage } from '~/graphql/types';
    import QUERY from './Query';
    export default createPage({
    query: QUERY,
    queryVariables: ({ slug }) => ({ slug }),
    requireLogin: true,
    requirePermissions: ({ profile }) => profile.canManage,
    requireFeature: 'feature_flag',
    tags: ({ profile }) => profile.seoTags,
    title: ({ profile }) => profile.name,
    component: ({ data: { profile } }) => (
    {...}
    ),
    });

    View Slide

  158. import createPage from '~/utils/createPage';
    import ProfileLayout from '~/layouts/Profile';
    import { ProfileShowPage } from '~/graphql/types';
    import QUERY from './Query';
    export default createPage({
    query: QUERY,
    queryVariables: ({ slug }) => ({ slug }),
    requireLogin: true,
    requirePermissions: ({ profile }) => profile.canManage,
    requireFeature: 'feature_flag',
    tags: ({ profile }) => profile.seoTags,
    title: ({ profile }) => profile.name,
    component: ({ data: { profile } }) => (
    {...}
    ),
    });

    View Slide

  159. import createPage from '~/utils/createPage';
    import ProfileLayout from '~/layouts/Profile';
    import { ProfileShowPage } from '~/graphql/types';
    import QUERY from './Query';
    export default createPage({
    query: QUERY,
    queryVariables: ({ slug }) => ({ slug }),
    requireLogin: true,
    requirePermissions: ({ profile }) => profile.canManage,
    requireFeature: 'feature_flag',
    tags: ({ profile }) => profile.seoTags,
    title: ({ profile }) => profile.name,
    component: ({ data: { profile } }) => (
    {...}
    ),
    });

    View Slide

  160. import createPage from '~/utils/createPage';
    import ProfileLayout from '~/layouts/Profile';
    import { ProfileShowPage } from '~/graphql/types';
    import QUERY from './Query';
    export default createPage({
    query: QUERY,
    queryVariables: ({ slug }) => ({ slug }),
    requireLogin: true,
    requirePermissions: ({ profile }) => profile.canManage,
    requireFeature: 'feature_flag',
    tags: ({ profile }) => profile.seoTags,
    title: ({ profile }) => profile.name,
    component: ({ data: { profile } }) => (
    {...}
    ),
    });

    View Slide

  161. View Slide

  162. http://graphql.org/

    View Slide

  163. View Slide

  164. ViewerFragme
    ProfileLayoutHeaderFragment
    ProfileLayout
    MenuFragme
    nt
    ProfileShowPage

    View Slide

  165. ViewerFragme
    ProfileLayout
    MenuFragme
    nt
    FollowButto
    Avatar
    Fragment
    ProTips
    Fragment
    Stack
    Fragment

    View Slide

  166. ViewerFragme
    ProfileLayout
    MenuFragme
    nt
    FollowButto
    Avatar
    Fragment
    Avata
    r
    Card
    LikeButton

    View Slide

  167. Query
    Fragm Fragm
    Fragm
    Fragm
    Fragm
    Fragm

    View Slide

  168. import gql from 'graphql-tag';
    import AnswerCardWithQuestionFragment from '~/components/Answer/Card/FragmentWithQue
    import DoYouUseFragment from './DoYouUse/Fragment';
    import HeadTagsFragment from '~/utils/createPage/HeadTagsFragment';
    import ProfileAvatarLinkFragment from '~/components/Profile/AvatarLink/Fragment';
    import ProfileLayoutFragment from '~/layouts/Profile/Fragment';
    import ProfilePeopleSectionFragment from '~/components/Profile/PeopleSection/Fragmen
    import RecommendedProductsFragment from './RecommendedProducts/Fragment';
    import StackItemProfileFragment from '~/components/Stack/Item/Fragment';
    import TipCardFragment from '~/components/Tip/Card/Fragment';
    export default gql`
    query ProfilesShowPage($slug: String!) {
    profile(slug: $slug) {
    id
    answersCount
    canManage
    likedAnswersCount
    questionsCount
    tipsCount
    whitelisted
    using(first: 8) {
    edges {
    node {
    id
    note

    View Slide

  169. import StackItemProfileFragment from '~/components/Stack/Item/Fragment';
    import TipCardFragment from '~/components/Tip/Card/Fragment';
    export default gql`
    query ProfilesShowPage($slug: String!) {
    profile(slug: $slug) {
    id
    answersCount
    canManage
    likedAnswersCount
    questionsCount
    tipsCount
    whitelisted
    using(first: 8) {
    edges {
    node {
    id
    note
    profileTo {
    id
    name
    ...ProfileAvatarLinkFragment
    ...StackItemProfileFragment
    }
    }
    }
    }
    answers(first: 3) {

    View Slide

  170. }
    }
    tips(first: 1) {
    edges {
    node {
    id
    ...TipCardFragment
    }
    }
    }
    peopleWithSimilarInterests(limit: 4) {
    edges {
    node {
    id
    ...ProfilePeopleSectionFragment
    }
    }
    }
    ...HeadTagsFragment
    ...ProfileLayoutFragment
    ...ProfilesShowDoYouUseFragment
    ...ProfilesShowDoYouUseFragment
    }
    }
    ${AnswerCardWithQuestionFragment}
    ${DoYouUseFragment}
    ${HeadTagsFragment}
    ${ProfileAvatarLinkFragment}

    View Slide

  171. View Slide

  172. Recap

    View Slide

  173. . GraphQL
    # Components
    4 isolating dependancies
    ' directory as folder
    / domain components
    , Pages
    - paths helper
    & layouts
    % createPage
    5 Recap

    View Slide

  174. View Slide

  175. View Slide

  176. Thanks 6

    View Slide