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.

egghead
egghead
~ 4 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today