-
Notifications
You must be signed in to change notification settings - Fork 221
Closed
Labels
closing soonThis issue will be closed in 7 days unless further comments are made.This issue will be closed in 7 days unless further comments are made.datastoreIssues related to the DataStore categoryIssues related to the DataStore categorypending-community-responseIssue is pending response from the issue requestorIssue is pending response from the issue requestor
Description
I have been unable to create a many-to-many relationship with the current api.
I started with the following model:
type Person @model {
id: ID!
fullName: String!
nationality: [Nationality] @connection(keyName: "byCountry", fields: ["id"])
}
type Nationality
@model(queries: null)
@key(name: "byCountry", fields: ["personID", "countryID"])
@key(name: "byCitizen", fields: ["countryID", "personID"]) {
id: ID!
personID: ID!
countryID: ID!
person: Person! @connection(fields: ["personID"])
country: Country! @connection(fields: ["countryID"])
}
type Country @model {
id: ID!
name: String!
citizens: [Nationality] @connection(keyName: "byCitizen", fields: ["id"])
}
The model generation will create an instance:
public struct Nationality: Model {
public let id: String
public var person: Person
public var country: Country
public init(id: String = UUID().uuidString,
person: Person,
country: Country) {
self.id = id
self.person = person
self.country = country
}
}
Which seems perfectly fine until you call the mutation and get the following error:
[Amplify.GraphQLError(message: "Variable \'input\' has coerced Null value for NonNull type \'CountryInput!\'", locations: Optional([Amplify.GraphQLError.Location(line: 1, column: 41)]), path: nil, extensions: nil)]
Trying out the endpoint directly in console/AppSync/Query I can see the mutation requires me to provide more than just the ids, it requires the the instances of person and country as well and it seems the generated code isn't doing it for me.
Is this a bug of the generator, a more fundamental issue or am I doing something wrong here?
Metadata
Metadata
Assignees
Labels
closing soonThis issue will be closed in 7 days unless further comments are made.This issue will be closed in 7 days unless further comments are made.datastoreIssues related to the DataStore categoryIssues related to the DataStore categorypending-community-responseIssue is pending response from the issue requestorIssue is pending response from the issue requestor