1. 2
    Model our Application Data with a GraphQL Schema
    1m 59s

Model our Application Data with a GraphQL Schema

Share this video with your friends

Send Tweet

The next step is to model the data that we are going to use for our application, we'll have a Shop and Product. Shops will 'have many' Products.

You'll see how to type this in a GraphQL schema with the different properties we want on Shop and Product. Additionally we will be introduced to the faunadb @relation directive which is similar to a foreign key constraint.

Read more about the @relation directive in the docs.

# schema.graphql
type Shop {
  name: String!
  description: String!
  coverImg: String!
  products: [Product]!
  ownerID: String!
}

type Product {
  name: String!
  description: String!
  price: Float!
  category: String!
  shop: Shop! @relation
}