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

GraphQL: Not just for Facebook anymore

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

GraphQL: Not just for Facebook anymore

I did a short talk at our local Frontend Meetup in Aalborg. Slides are for anyone interested.

Avatar for Andri Óskarsson

Andri Óskarsson

October 09, 2019

Other Decks in Technology

Transcript

  1. Hi! I'm Andri Computer Engineer from Iceland React user since

    2016 GraphQL in production since 2018 Co-organiser at Aalborg Frontend Meetup @andrioid on Twitter
  2. Goal of this talk Hopefully convince you of the benefits

    of using GraphQL What is GraphQL Problems we didn't knew we had GraphQL features How to get started
  3. What is GraphQL? Made by Facebook for their "Graph API"

    Describes API layouts, types and data Language and protocol agnostic Not a graph. More like a tree.
  4. Backend decides Multiple API calls per view Frontend does data

    processing and object merging Messy frontend code Lodash is a symptom, not a cure
  5. Frontend decides Backend views created on API endpoint (combined data)

    Backend needs to add every field Performance implications Code duplication Messy backend code
  6. Developers lose Maybe not a big loss, but loss Different

    departments have different priorities Maybe different work-load between frontend/backend
  7. Keeps the frontend clean No need for const moo =

    animals && animals.mammals && animals.mammals.cow && animals.mammals.cow.says(); When you know exactly what the data looks like Focus on the presentation, not the data
  8. Documentation Discover an API with introspect queries Local and remote

    tools Descriptions and type definitions Deprecated? Just add @deprecated
  9. Frontend Apollo Client (React, Angular, Vue, Native iOS/Android) (I recommend

    it) Urql (React) From Formiddable Labs Relay modern From Facebook
  10. Backend Languages JS/TypeScript Apollo Server Go gqlgen PHP graphql-php Ready

    to use (JAMstack) GraphCMS Prime Strapi And many more
  11. Schema type Meetupee { id: ID! name: String! friends: [Meetupee!]!

    } type Query { allMeetupees: [Meetupee!] } type Mutation { renameMeetupee(id: ID!, newName: String!) Meetupee! } schema { query: Query, mutation: Mutation }
  12. Mutations Changes to data are called mutations. Idiomatic to return

    the object changed. mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) { createReview(episode: $ep, review: $review) { stars commentary } }
  13. Resolver Knows how to get data for a certain type.

    From database From external API From memory GraphQL doesn't care
  14. Thanks for your time! If you want to know more,

    come find me after the talk.