Skip to content

Commit

Permalink
update rest of the schema files
Browse files Browse the repository at this point in the history
  • Loading branch information
lawmicha committed Oct 22, 2021
1 parent 04325eb commit 653aa68
Show file tree
Hide file tree
Showing 36 changed files with 80 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public struct MutationSync<ModelType: Model>: Decodable {
case let .number(version) = json["_version"] else {

// TODO query name could be useful for the message, but re-creating it here is not great
let queryName = "sync\(modelType.schema.syncPluralName ?? modelType.schema.pluralName ?? modelType.modelName)"
let queryName = modelType.schema.syncPluralName ?? modelType.schema.pluralName ?? modelType.modelName
throw DataStoreError.decodingError(
"""
Error decoding the the sync metadata from the delta sync query result.
""",
"""
The sync metadata should contain fields named `_deleted`, `_lastChangedAt` and `_version`.
Check your `\(queryName)` query and make sure it returns the correct set of sync fields.
Check your sync`\(queryName)` query and make sure it returns the correct set of sync fields.
"""
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public struct OIDCGroupPost: Model {
operations: [.create, .update, .delete, .read])
]

model.pluralName = "OIDCGroupPosts"
model.listPluralName = "OIDCGroupPosts"
model.syncPluralName = "OIDCGroupPosts"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public struct OIDCMultiGroupPost: Model {
groups: ["Moderators", "Editors"],
operations: [.create, .update, .delete, .read])
]
model.pluralName = "OIDCMultiGroupPosts"
model.listPluralName = "OIDCMultiGroupPosts"
model.syncPluralName = "OIDCMultiGroupPosts"
model.fields(
.id(),
.field(oIDCMultiGroupPost.title, is: .required, ofType: .string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GraphQLRequestEmbeddableTypeJSONTests: XCTestCase {
let colorR = ModelField(name: "red", type: .int, isRequired: true)
let colorG = ModelField(name: "green", type: .int, isRequired: true)
let colorB = ModelField(name: "blue", type: .int, isRequired: true)
let colorSchema = ModelSchema(name: "Color", pluralName: "Colors",
let colorSchema = ModelSchema(name: "Color", listPluralName: "Colors", syncPluralName: "Colors",
fields: [colorName.name: colorName,
colorR.name: colorR,
colorG.name: colorG,
Expand All @@ -34,7 +34,7 @@ class GraphQLRequestEmbeddableTypeJSONTests: XCTestCase {
let categoryColor = ModelField(name: "color",
type: .embeddedCollection(of: DynamicEmbedded.self, schema: colorSchema),
isRequired: true)
let categorySchema = ModelSchema(name: "Category", pluralName: "Categories",
let categorySchema = ModelSchema(name: "Category", listPluralName: "Categories", syncPluralName: "Categories",
fields: [categoryName.name: categoryName,
categoryColor.name: categoryColor])

Expand All @@ -47,7 +47,8 @@ class GraphQLRequestEmbeddableTypeJSONTests: XCTestCase {
type: .embedded(type: DynamicEmbedded.self, schema: sectionSchema))
let todoStickies = ModelField(name: "stickies", type: .embedded(type: String.self))
let todoSchema = ModelSchema(name: "Todo",
pluralName: "Todos",
listPluralName: "Todos",
syncPluralName: "Todos",
fields: [todoId.name: todoId,
todoName.name: todoName,
todoDescription.name: todoDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GraphQLRequestJSONNonModelTests: XCTestCase {
let colorB = ModelField(name: "blue",
type: .int,
isRequired: true)
let colorSchema = ModelSchema(name: "Color", pluralName: "Colors",
let colorSchema = ModelSchema(name: "Color", listPluralName: "Colors", syncPluralName: "Colors",
fields: [colorName.name: colorName,
colorR.name: colorR,
colorG.name: colorG,
Expand All @@ -110,7 +110,7 @@ class GraphQLRequestJSONNonModelTests: XCTestCase {
let categoryColor = ModelField(name: "color",
type: .embeddedCollection(of: DynamicEmbedded.self, schema: colorSchema),
isRequired: true)
let categorySchema = ModelSchema(name: "Category", pluralName: "Categories",
let categorySchema = ModelSchema(name: "Category", listPluralName: "Categories", syncPluralName: "Categories",
fields: [categoryName.name: categoryName,
categoryColor.name: categoryColor])

Expand All @@ -127,13 +127,14 @@ class GraphQLRequestJSONNonModelTests: XCTestCase {
let todoStickies = ModelField(name: "stickies",
type: .embedded(type: String.self))
let todoSchema = ModelSchema(name: "Todo",
pluralName: "Todos",
fields: [todoId.name: todoId,
todoName.name: todoName,
todoDescription.name: todoDescription,
todoCategories.name: todoCategories,
todoSection.name: todoSection,
todoStickies.name: todoStickies])
listPluralName: "Todos",
syncPluralName: "Todos",
fields: [todoId.name: todoId,
todoName.name: todoName,
todoDescription.name: todoDescription,
todoCategories.name: todoCategories,
todoSection.name: todoSection,
todoStickies.name: todoStickies])

ModelRegistry.register(modelType: DynamicModel.self,
modelSchema: todoSchema) { (_, _) -> Model in
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/2/Project2+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ extension Project2 {
public static let schema = defineSchema { model in
let project2 = Project2.keys

model.pluralName = "Project2s"
model.listPluralName = "Project2s"
model.syncPluralName = "Project2s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/2/Team2+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ extension Team2 {
public static let schema = defineSchema { model in
let team2 = Team2.keys

model.pluralName = "Team2s"
model.listPluralName = "Team2s"
model.syncPluralName = "Team2s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/3/Comment3+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Comment3 {
public static let schema = defineSchema { model in
let comment3 = Comment3.keys

model.pluralName = "Comment3s"
model.listPluralName = "Comment3s"
model.syncPluralName = "Comment3s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/3/Post3+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Post3 {
public static let schema = defineSchema { model in
let post3 = Post3.keys

model.pluralName = "Post3s"
model.listPluralName = "Post3s"
model.syncPluralName = "Post3s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/4/Comment4+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Comment4 {
public static let schema = defineSchema { model in
let comment4 = Comment4.keys

model.pluralName = "Comment4s"
model.listPluralName = "Comment4s"
model.syncPluralName = "Comment4s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/4/Post4+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Post4 {
public static let schema = defineSchema { model in
let post4 = Post4.keys

model.pluralName = "Post4s"
model.listPluralName = "Post4s"
model.syncPluralName = "Post4s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/5/Post5+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Post5 {
public static let schema = defineSchema { model in
let post5 = Post5.keys

model.pluralName = "Post5s"
model.listPluralName = "Post5s"
model.syncPluralName = "Post5s"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension PostEditor5 {
public static let schema = defineSchema { model in
let postEditor5 = PostEditor5.keys

model.pluralName = "PostEditor5s"
model.listPluralName = "PostEditor5s"
model.syncPluralName = "PostEditor5s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/5/User5+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension User5 {
public static let schema = defineSchema { model in
let user5 = User5.keys

model.pluralName = "User5s"
model.listPluralName = "User5s"
model.syncPluralName = "PostEditor5s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/6/Blog6+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Blog6 {
public static let schema = defineSchema { model in
let blog6 = Blog6.keys

model.pluralName = "Blog6s"
model.listPluralName = "Blog6s"
model.syncPluralName = "Blog6s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/6/Comment6+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Comment6 {
public static let schema = defineSchema { model in
let comment6 = Comment6.keys

model.pluralName = "Comment6s"
model.listPluralName = "Comment6s"
model.syncPluralName = "Comment6s"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Collection/6/Post6+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ extension Post6 {
public static let schema = defineSchema { model in
let post6 = Post6.keys

model.pluralName = "Post6s"
model.listPluralName = "Post6s"
model.syncPluralName = "Post6s"

model.fields(
.id(),
Expand Down
2 changes: 1 addition & 1 deletion AmplifyTestCommon/Models/Comment+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Comment {

public static let schema = defineSchema { model in
let comment = Comment.keys

model.listPluralName = "Comments"
model.syncPluralName = "Comments"

Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/CustomerOrder+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension CustomerOrder {
public static let schema = defineSchema { model in
let customerOrder = CustomerOrder.keys

model.pluralName = "CustomerOrders"
model.listPluralName = "CustomerOrders"
model.syncPluralName = "CustomerOrders"
model.attributes(.index(fields: ["orderId", "id"], name: nil))
model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension M2MPost {
public static let schema = defineSchema { model in
let m2MPost = M2MPost.keys

model.pluralName = "M2MPosts"
model.listPluralName = "M2MPosts"
model.syncPluralName = "M2MPosts"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension M2MPostEditor {
public static let schema = defineSchema { model in
let m2MPostEditor = M2MPostEditor.keys

model.pluralName = "M2MPostEditors"
model.listPluralName = "M2MPostEditors"
model.syncPluralName = "M2MPostEditors"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension M2MUser {
public static let schema = defineSchema { model in
let m2MUser = M2MUser.keys

model.pluralName = "M2MUsers"
model.listPluralName = "M2MUsers"
model.syncPluralName = "M2MUsers"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/NonModel/Todo+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ extension Todo {
public static let schema = defineSchema { model in
let todo = Todo.keys

model.pluralName = "Todos"
model.listPluralName = "Todos"
model.syncPluralName = "Todos"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ extension Transaction {
public static let schema = defineSchema { model in
let transaction = Transaction.keys

model.pluralName = "Transactions"
model.listPluralName = "Transactions"
model.syncPluralName = "Transactions"

model.fields(
.id()
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Restaurant/Dish+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Dish {
public static let schema = defineSchema { model in
let dish = Dish.keys

model.pluralName = "Dishes"
model.listPluralName = "Dishes"
model.syncPluralName = "Dishes"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Restaurant/Menu+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ extension Menu {
public static let schema = defineSchema { model in
let menu = Menu.keys

model.pluralName = "Menus"
model.listPluralName = "Menus"
model.syncPluralName = "Menus"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Restaurant/Restaurant+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Restaurant {
public static let schema = defineSchema { model in
let restaurant = Restaurant.keys

model.pluralName = "Restaurants"
model.listPluralName = "Restaurants"
model.syncPluralName = "Restaurants"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Scalar/EnumTestModel+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ extension EnumTestModel {
public static let schema = defineSchema { model in
let enumTestModel = EnumTestModel.keys

model.pluralName = "EnumTestModels"
model.listPluralName = "EnumTestModels"
model.syncPluralName = "EnumTestModels"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ extension ListIntContainer {
public static let schema = defineSchema { model in
let listIntContainer = ListIntContainer.keys

model.pluralName = "ListIntContainers"
model.listPluralName = "ListIntContainers"
model.syncPluralName = "ListIntContainers"

model.fields(
.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ extension ListStringContainer {
public static let schema = defineSchema { model in
let listStringContainer = ListStringContainer.keys

model.pluralName = "ListStringContainers"
model.listPluralName = "ListStringContainers"
model.syncPluralName = "ListStringContainers"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Scalar/Nested+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ extension Nested {
public static let schema = defineSchema { model in
let nested = Nested.keys

model.pluralName = "Nesteds"
model.listPluralName = "Nesteds"
model.syncPluralName = "Nesteds"

model.fields(
.field(nested.valueOne, is: .optional, ofType: .int),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ extension NestedTypeTestModel {
public static let schema = defineSchema { model in
let nestedTypeTestModel = NestedTypeTestModel.keys

model.pluralName = "NestedTypeTestModels"
model.listPluralName = "NestedTypeTestModels"
model.syncPluralName = "NestedTypeTestModels"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/Scalar/ScalarContainer+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ extension ScalarContainer {
public static let schema = defineSchema { model in
let scalarContainer = ScalarContainer.keys

model.pluralName = "ScalarContainers"
model.listPluralName = "ScalarContainers"
model.syncPluralName = "ScalarContainers"

model.fields(
.id(),
Expand Down
3 changes: 2 additions & 1 deletion AmplifyTestCommon/Models/TeamProject/Project+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension Project {
public static let schema = defineSchema { model in
let project = Project.keys

model.pluralName = "Projects"
model.listPluralName = "Projects"
model.syncPluralName = "Projects"

model.fields(
.id(),
Expand Down
Loading

0 comments on commit 653aa68

Please sign in to comment.