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.
You must be a Pro Member to view code
Access all courses and lessons, track your progress, gain confidence and expertise.
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.