Closed lawmicha closed 1 month ago
In the subsequent example, https://docs.amplify.aws/swift/build-a-backend/data/customize-authz/multi-user-data-access/#override-to-a-list-of-owners
we explicitly override the owners field array as "authors"
const schema = a.schema({
Todo: a
.model({
content: a.string(),
authors: a.string().array(), // record owner information now stored in "authors" field
})
.authorization(allow => [allow.ownersDefinedIn('authors')]),
});
Maybe In the first example, as a workaround, I can do this:
const schema = a.schema({
Todo: a
.model({
content: a.string(),
owners: a.string().array(), // record owner information now stored in "authors" field
})
.authorization(allow => [allow.ownersDefinedIn('owners')]),
});
Looks like this may be a data-schema issue or an existing issue also affecting Gen 1. The transformation for the schema:
a
.model({
content: a.string(),
}).authorization(allow => [allow.ownersDefinedIn('owners')]),
resolves to a GraphQL schema:
type Todo @model @auth(rules: [{allow: owner, ownerField: "owners"}])
{
content: String
}
The owners
field is not present.
So either:
owners
field.Ok, got some clarification. This is a docs issue. The customer needs to explicitly add the owner field to the schema. owners: a.string().array()
.
Got it, this is the schema i'm using my test. I can update the docs with the explicit field
Todo15: a
.model({
content: a.string(),
owners: a.string().array(),
}).authorization(allow => [allow.ownersDefinedIn('owners')]),
Thanks Michael!
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
From the docs https://docs.amplify.aws/swift/build-a-backend/data/customize-authz/multi-user-data-access/#add-multi-user-authorization-rule
I'm using the schema
In the TS code snippet, there's
owners
field array is updated withotherUserId
.I can't do that the Swift generated models since there is no owner field exposed. The Swift generated models
Todo15.swift
Todo15+Schema.swift
Package.json for Gen2 versions