Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Query the GitHub GraphQL API


    One of the first major companies to launch a public GraphQL API was GitHub. In this lesson, we'll send queries to the GitHub API to view our own data, and we'll get acquainted with some of the core features of the GraphQL query language.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: To start, you can go to developer.github.com/v4/explorer. Then you can click on "Sign in with GitHub" to log into the Explorer so that you can start sending queries. On the left side in the GraphiQL window, let's write a query for viewer. Viewer is whoever is logged in.

    We'll also request the fields for login, bio, and company. When you hit "play," you'll the response from the query on the right side as JSON. All of the fields in the response match the fields in the query.

    GraphQL APIs are self-documenting. If I click on "query," you'll see a list of all of the available queries. At the bottom is our viewer query. If I click on that, you'll see that this returns the type user.

    Then you can click on "user" to show all of the available fields on the user type. You can also surface the queryable fields within GraphiQL itself by hitting control-space anywhere in your query.