-
Notifications
You must be signed in to change notification settings - Fork 222
Description
Describe the bug
Error:
Failed to create graphql GraphQLResponseError<Like>: GraphQL service returned a partially-successful response containing errors: [Amplify.GraphQLError(message: "Cannot return null for non-nullable type: \'ID\' within parent \'User\' (/createLike/user/id)", locations: nil, path: Optional([Amplify.JSONValue.string("createLike"), Amplify.JSONValue.string("user"), Amplify.JSONValue.string("id")]), extensions: nil)]
Following code used to work, but after upgrading to newer version of Amplify, it starts to fall apart. I don't need associated entities when doing Amplify.API.mutate, and I suppose the backend shouldn't query associated entities by default, but somehow the response deserializer start to demand the associated entity which supposed to be optional.
let like = Like(
subjectId: subjectId,
userId: userId,
subjectType: subjectType,
subjectOwnerId: subjectOwnerId
)
let request: GraphQLRequest<Like> = toLike ? .create(like) : .delete(like)
let result = try await Amplify.API.mutate(request: request)
Following are model schema
type Like @model
@auth(rules: [
{ allow: private, provider: userPools, operations: [read] },
{ allow: owner, provider: userPools, operations: [create, update, delete], ownerField: "userId", identityClaim: "sub" }
]) {
subjectId: ID! @primaryKey(sortKeyFields: ["userId"])
userId: ID!
subjectType: String
subjectOwnerId: ID
user: User @hasOne(fields: ["userId"])
}
type User @model {
id: ID!
name: String
portrait: String
bio: String
isDeleted: Boolean
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
Steps To Reproduce
See code above
Expected behavior
should not throw exception
Amplify Framework Version
2.29.2
Amplify Categories
API
Dependency manager
Swift PM
Swift version
5.x
CLI version
12.13.0
Xcode version
15.3
Relevant log output
<details>
<summary>Log Messages</summary>
INSERT LOG MESSAGES HERE
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
17.0
Device
iPhone14
Specific to simulators
No response
Additional context
No response