Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Youtube

Github Stackoverflow Pinterest

Now THIS is the industry standard. REST API is so last season.


Overview

GraphQL was invented within Facebook.

http://graphql.org/blog says:

GraphQL has been delivering data to Facebook mobile News Feed since 2012.

Facebook released it publicly in 2015 at:
http://facebook.github.io/graphql

Community stats

The status of community as of November 5, 2015:

“GraphQL is the new standard for data API from Facebook, superseding REST. It allows a single data graph with strongly typed schema to serve just as much data as needed from a client. GitHub is switching to GraphQL already.”

There are Google Groups for specific implementations:

Why?

It was a necessity for the world’s busiest mobile app for these advantages over REST API:

  • Perform an introspection query. As the GraphQL schema matures, new data types appear.

  • Make a single call to retrieve (rather than many REST API calls).

  • Response is structured using the same JSON hierarchy as the call. A shared schema language between front-end and back-end. This is hugh.

  • Changes can occur with less fuss (pain) than REST API. No large version migrations.

  • Static queries make loading predictable, and cleaner server metric insights.

  • Schema says which fields are being used, so caching (persisted queries) is possible.

    “With GraphQL, we could simply stop writing API documentation or reading it. I think that’s the dream of every developer.” - by @arunoda

Facebook Relay vs. Apollo

Facebook also released its Relay server that responds to GraphQL queries. It’s a JS framework based on React Redux.

CAUTION: Look at the licensing statements from Facebook. You should not use works from Facebook if you might have a product that might infringe on something Facebook may do in the future, such as any social networking, including IoT.

An alternative is SPARQL used in IoT.

https://dev-blog.apollodata.com/ is based on React Redux, React Native

Apollodata.com/Optics provides metrics: execution traces, field latencies, field usage

Scaphold.io provides a SaaS cloud platform using either Relay or Apollo starter kits at
https://github.com/scaphold-io and explained on their YouTube channel

Clients

Client features

  • Query builder
  • Cache
  • Retry
  • Error handling
  • Rollback

  • Conditional fetching
  • Mutations
  • Fragments group commonly used fields and reuses them.
  • Optimistic UI
  • Pagination

Examples

GraphQL is a data description language and not a programming language

TODO: Example code

Rock Stars

OG GraphQL co-creators at Facebook:

  • Lee Byron (@leeb, leebyron.com)

  • Nicolas Schrock

  • Daniel Schafer

Relay creators at Facebook:

  • Joe Savona (@en_JS)

  • Steven Luscher

  • Greg Hurrell

Meteor Development Group / ApolloData.com / GitHub.com/apollostack

  • CEO Geoff Schmidt (@immir)

  • VP of Product Matt DeBergalis

  • Sashko Stubailo (@stubailo) Slidshare

  • Apollo Services Danielle Man (@danimman)

User GitHub:

  • Brandon Black

User Coursera:

  • Brennan Saeta (@bsaeta)

  • Founder Andrew Ng (@AndrewYNg) on Machine Learning

Users:

  • Kenton Jacobsen from Conde Nast
  • Nick Nance from Credit Karma
  • Mike Isman from Hudl
  • Aaron Weiker from Concur

Resources

The Awesome list for GraphQL

DataLoader to reduce over-fetching (one record several times)

Relay

PowerShellforGitHubGraphQL module

I couldn’t find a PSGallery module for referencing GitHub’s GraphQL, so I set out to create one when that’s what Karol Kaczmarek suggested I do.

PowerShell for GitHub GraphQL

More on API Microservices

This is one of a series: