-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
- Amplify Swift codegen generates incorrect syntax when custom types reference
@model
types in GraphQL schema.

Steps To Reproduce
1. Create AppSync API with sample schema which uses custom types reference @model types in GraphQL schema.
type Product @model {
id: ID! @primaryKey
name: String!
price: Float!
}
type OrderSummary {
orderId: ID!
product: Product! # References @model type
quantity: Int!
}
type Mutation {
createOrder(productId: ID!, quantity: Int!): OrderSummary
@function(name: "createOrder-${env}")
}
2. Generate models using `amplify codegen models`
3. Check and Verify generated model swift file and use it your application.
// swiftlint:disable all
import Amplify
import Foundation
extension OrderSummary {
// MARK: - CodingKeys
public enum CodingKeys: String, ModelKey {
case orderId
case product
case quantity
}
public static let keys = CodingKeys.self
// MARK: - ModelSchema
public static let schema = defineSchema { model in
let orderSummary = OrderSummary.keys
model.listPluralName = "OrderSummaries"
model.syncPluralName = "OrderSummaries"
model.fields(
.field(orderSummary.orderId, is: .required, ofType: .string),
.field(orderSummary.product, is: .required, ofType: .model(Product.self)),
.field(orderSummary.quantity, is: .required, ofType: .int)
)
}
}
4. You will get error `Missing argument label 'type:' in call`
Expected behavior
Problem: Generated code produces:
model(Product.self) // Missing 'type:' parameter
.model(type: Product.self) // Correct syntax
Amplify Framework Version
2.50.0
Amplify Categories
API
Dependency manager
Swift PM
Swift version
Swift 6.1.2
CLI version
14.0.0
Xcode version
16.4
Relevant log output
<details>
<summary>Log Messages</summary>
INSERT LOG MESSAGES HERE
</details>
Is this a regression?
No
Regression additional context
No response
Platforms
No response
OS Version
macOS 15.0
Device
Iphone 16 pro
Specific to simulators
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working