This video is available to students only

Getting GitHub GraphQL schema

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

Previous LessonDefining the WelcomeWindow layoutNext LessonGenerating the types

Lesson Transcript

  • [00:00 - 00:13] Getting GitHub GraphQL schema. We've just written our first query, but we had to provide the types for it manually. In fact, type information is already available in the GraphQL schema, and we just need to extract it to use with TypeScript.

  • [00:14 - 00:23] To extract the type information, we need to obtain the full GraphQL schema definition. The Apollo CLI allows to do this. Let's install it as a dev dependency. Yarn.

  • [00:24 - 00:31] Add -dev Apollo. The request that we are going to make requires authentication, so we'll need to get the bearer token.

  • [00:32 - 00:39] Lucky for us, we already have it because we made an authenticated request to retrieve the user data. Run the following command to get the authentication token.

  • [00:40 - 00:46] It is just an old script, and you can copy it from the text version of this lesson. Run it in the console, and you should get your token.

  • [00:47 - 00:51] Now run the next command. Run Yarn.run.Apollo. schema.download.

  • [00:52 - 01:04] -hedra. And here you pass the token that you got on the previous step, instead of the token in the triangular brackets. Specify the endpoint and the file where you want to store your JSON schema.

  • [01:05 - 01:09] Let's run this command. Loding the schema. And now it is stored in the JSON file.

  • [01:10 - 01:14] You can find it in the GraphQL schema JSON in the root of your project.

This lesson preview is part of the Fullstack React with TypeScript Masterclass course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

Unlock This Course

Get unlimited access to Fullstack React with TypeScript Masterclass, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Fullstack React with TypeScript Masterclass