Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active May 14, 2020 00:13
Show Gist options
  • Save dabit3/c67778909722d64bb452de81c1895d4f to your computer and use it in GitHub Desktop.
Save dabit3/c67778909722d64bb452de81c1895d4f to your computer and use it in GitHub Desktop.
Amplify GraphQL Schema with different access patterns
type Product @model
@key(name: "productInventoryAmountIndex", fields: ["baseType", "inventory"], queryField: "productsByInventoryAmount")
@key(name: "productInventoryPriceIndex", fields: ["baseType", "price"], queryField: "productsByPrice")
@key(name: "productNameSearchIndex", fields: ["baseType", "name"], queryField: "productSearchByName")
@key(name: "productCategorySearchIndex", fields: ["baseType", "category"], queryField: "productSearchByCategory")
@key(name: "productCategoryIndex", fields: ["category", "createdAt"], queryField: "productsByCategory")
@key(name: "productByCategoryAndNameIndex", fields: ["category", "name"], queryField: "productsByCategoryAndName")
@key(name: "productByCategoryAndInventoryIndex", fields: ["category", "inventory"], queryField: "productsByCategoryAndInventory")
@key(name: "productByCategoryAndPriceIndex", fields: ["category", "price"], queryField: "productsByCategoryAndPrice")
{
id: ID
name: String
price: Float
category: String
inventory: Int
createdAt: String
baseType: String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment