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

Building a Better GitHub Platform with GraphQL

Building a Better GitHub Platform with GraphQL

Brandon Black

October 26, 2016
Tweet

More Decks by Brandon Black

Other Decks in Programming

Transcript

  1. GitHub Platform Today 3 • Home to over 38 million

    projects, central location for most modern open-source software. • A collaborative community of over 15 million people learning, sharing and working together every day. • Over 250,000 OAuth applications building on the platform. • Over 6 million users have OAuth apps installed. • Broad eco-system of innovative integrators and developers building rich user experiences and critical developer tools through the REST API and web hooks.
  2. GitHub Thinking About Tomorrow 4 Internally • Be forward thinking

    about how we build out services internally. • Add additional diversity to our tech stack. • Simplify and improve how we work across teams, make development a seamless experience. • Create a back-end layer that everyone can contribute to. • Improve how our own off-site clients interact with GitHub’s platform back-end.
  3. GitHub Externally • Be more transparent with the community we

    support. • Getting the data you want today can require multiple, often many REST calls away. • Close the feature gap for external developers. • Improve platform engagement and adoption through better tooling, documentation and on-boarding resources. Thinking About Tomorrow 5
  4. GitHub Why GraphQL? 7 What We Liked… • Why not

    X? GraphQL had a clear value proposition and a light weight unopinionated spec. • GraphQL had strong and very lively support from the greater open-source community. • It was an opportunity to collaborate with the community. • It helps pave the way for many of the goals we have for GitHub’s platform. • It changes the way we ship — in a good way.
  5. GitHub Challenges 8 • Mitigating the Management Overhead of Multiple

    Schemas • Security and Privacy • Versioning, Behavioral and Breaking Changes • Performance Optimization and Resilience • On-boarding — Removing Roadblocks for Adoption • Instrumentation and Monitoring • Managing GraphQL Interface Contributions
  6. GitHub Open-Source 9 GraphQL Client (Ruby) • Used internally to

    power many core GitHub features. • Provides integration and query validation in Rails views. • Handles query execution and query result parsing.
  7. GitHub Open-Source 10 GraphQL Client (Ruby) require "graphql/client" require "graphql/client/http"

    http = GraphQL::Client::HTTP.new("http://graphql-swapi.parseapp.com/") schema = GraphQL::Client.load_schema(http) client = GraphQL::Client.new(schema: schema, execute: http)
  8. GitHub Open-Source 11 GraphQL Client (Ruby) HumanFragment = client.parse <<-'GRAPHQL'

    fragment on Human { name homePlanet } GRAPHQL HeroNameQuery = client.parse <<-'GRAPHQL' { luke: human(id: "1000") { ...HumanFragment } leia: human(id: "1003") { ...HumanFragment } } GRAPHQL
  9. GitHub Open-Source 13 GraphQL Client (Ruby) <%# app/views/humans/human.html.erb %> <%graphql

    fragment HumanFragment on Human { name homePlanet } %> <p><%= human.name %> lives on <%= human.home_planet %>.</p>
  10. GitHub Open-Source 14 GraphQL Walker (Ruby) • Proactively identifies and

    hunts down node access discrepancies in your GraphQL interface. • Can easily be used directly along side GraphQL Client. • Written in Ruby, but useful for any GraphQL interface.
  11. GitHub Open-Source 15 GraphQL Walker (Ruby) require "graphql/relay/walker" id =

    "cGVvcGxlOjE=" query = GraphQL::Relay::Walker.query_string(schema) GraphQL::Relay::Walker.walk(from_id: id) do |frame| frame.gid frame.parent frame.result = execute(query, variables: {"id" => frame.gid}) frame.enqueue_found_gids end
  12. GitHub Open-Source 16 GraphQL Walker (Ruby) require "graphql/relay/walker/client_ext" id =

    "cGVvcGxlOjE=" GraphQL::Client.walk(from_id: id) do |frame| frame.gid frame.parent frame.result end