Unions and Indexing 10 exercises
Problem

Extract Object Properties into Individual Types

Here, we've got an object called fakeDataDefaults that acts as a mock GraphQL object for testing:


export const fakeDataDefaults = {
String: "Default string",
Int: 1,
Float: 1.14,
Boolean: true,
ID: "id",
}

When hovering over fakeDataDefaults we can see the types of each fi

Loading exercise

Transcript

0:00 Here, we've got an object called fakeDataDefaults. This is like imagine you wanted to put some fake data into a system for test. Then, you would have your GraphQL types here, so string, int, float, Boolean, ID.

0:12 Except, what we want to do is extract the type of these into their own types. These fakeDataDefaults, we can see the string is the result of string. Int is the result of a number. Float, number. Boolean, Boolean. ID, string.

0:26 We want to grab these and put them in here. That's your job, is to work out how we can both turn this into a type and extract the value of the object into each specific piece.