Skip to content

Instantly share code, notes, and snippets.

@IanPhilips
Created August 10, 2021 16:26
Show Gist options
  • Save IanPhilips/c8198357491c7ef618325b97d4fffd42 to your computer and use it in GitHub Desktop.
Save IanPhilips/c8198357491c7ef618325b97d4fffd42 to your computer and use it in GitHub Desktop.
graphql schema
type Product @model {
id: ID!
name: String!
priceID:String!
serviceAreas: [ProductOffering] @connection(keyName: "byServiceArea", fields: ["id"])
}
# Create a join model and disable queries as you don't need them
# and can query through Post.editors and User.posts
type ProductOffering
@model(queries: null)
@key(name: "byServiceArea", fields: ["serviceAreaID", "productID"])
@key(name: "byProduct", fields: ["productID", "serviceAreaID"]) {
id: ID!
productID: ID!
serviceAreaID: ID!
product: Product! @connection(fields: ["productID"])
serviceArea: ServiceArea! @connection(fields: ["serviceAreaID"])
}
type ServiceArea @model {
id: ID!
name: String!
products: [ProductOffering] @connection(keyName: "byProduct", fields: ["id"])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment