1. 8
    Update the Product GraphQL Data Model and Upload Changes to Fauna
    1m 10s

Update the Product GraphQL Data Model and Upload Changes to Fauna

Shadid Haque
InstructorShadid Haque
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years ago

Fauna is a flexible database so we can update our schema without breaking any existing functionality. You'll notice that our products all have hard coded images. In this lesson, we'll update our Product to include an image and import those changes to Fauna.

Shadid Haque: [0:00] Let's add a new field called imageUrl to our product. This is going to be a string type, and it is not required. Since Fauna is a flexible database, we can change our schema like this without breaking the existing data. Let's go ahead and merge our updated schema.

[0:22] I'll go to the product collection and add an imageUrl for one of these products. Let's head back to our code. We're going to add the imageUrl sub-selection to our query. Then, in our ProductItem component, we will replace the default image with the product's image if it exists.

[0:55] Finally, we'll head back to index again. We will destructure loading from useQuery and add some loading state for our page.