-
Notifications
You must be signed in to change notification settings - Fork 222
Closed
Labels
apiIssues related to the API categoryIssues related to the API categorybugSomething isn't workingSomething isn't working
Description
Describe the bug
Having the following schema
Household: a
.model({
name: a.string().required(),
memberUsers: a.hasMany('HouseholdUser', 'householdId'),
})
.authorization((allow) => [
allow.owner().to(['create', 'delete', 'read']),
allow.authenticated().to(['create', 'read']),
]),
HouseholdUser: a
.model({
name: a.string().required(),
email: a.string().required(),
householdId: a.id(),
household: a.belongsTo('Household', 'householdId'),
role: a.ref('HouseholdUserRole').required(),
createdTasks: a.hasMany('HouseholdTask', 'createdByUserId'),
assignedTasks: a.hasMany('HouseholdTask', 'assigneeUserId')
})
.authorization((allow) => [
allow.owner().to(['create', 'delete', 'read']),
allow.authenticated().to(['create','read']),
]),
with
authorizationModes: {
defaultAuthorizationMode: 'userPool',
},
Create each entity separately succeeds. However, assigning a user to a household with
let updatedUser = HouseholdUser(
id: user.id,
name: user.name,
email: user.email,
household: household,
role: user.role
)
let result = try await Amplify.API.mutate(request: .update(updatedUser))
fails with
An unknown error occurred: GraphQLResponseError<HouseholdUser>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Unauthorized on [name, email, householdId, role]", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: Optional([Amplify.JSONValue.string("updateHouseholdUser")]), extensions: Optional(["data": Amplify.JSONValue.null, "errorType": Amplify.JSONValue.string("Unauthorized"), "errorInfo": Amplify.JSONValue.null]))]
Recovery suggestion: The list of `GraphQLError` contains service-specific messages
Steps To Reproduce
1. Set up an amplify sandbox
2. Set up the schema, as above
3. Signup a new user, log in - all good
4. Create a household entity - all good
5. Try associate the household entity with the user - FAILS
Note that in Dynamo, I do NOT see houseHoldId column in my users table. Other properties are present as columns.
Expected behavior
I expect to be able to associate one entity with the other and have that reflected in Dynamo.
Amplify Framework Version
2.46.1
Amplify Categories
API
Dependency manager
Swift PM
Swift version
6.1
CLI version
12.14
Xcode version
16.3
Relevant log output
Successfully completed execution for Auth.fetchSessionAPI with result
Starting network task for mutation 93771BA6-A5DC-47CB-B3BC-CC0413D845B3
An unknown error occurred: GraphQLResponseError<HouseholdUser>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Unauthorized on [name, email, householdId, role]", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: Optional([Amplify.JSONValue.string("updateHouseholdUser")]), extensions: Optional(["data": Amplify.JSONValue.null, "errorType": Amplify.JSONValue.string("Unauthorized"), "errorInfo": Amplify.JSONValue.null]))]
Is this a regression?
Yes
Regression additional context
No response
Platforms
No response
OS Version
18.2
Device
Iphone 16 Pro
Specific to simulators
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
apiIssues related to the API categoryIssues related to the API categorybugSomething isn't workingSomething isn't working