Open Jesmaster opened 2 years ago
Hi @Jesmaster, thank you for raising this issue! I see two separate concerns here. First, that generated model fields (owner, _createdAt, etc.) are not generated in the output graphql schema. I'll fork that and treat as a feature request, which makes sense to expose. The second is that 'eq' in searchable isn't working with owner field for you. With the release of Amplify CLI version 8.1.0 a change was made to owner attributes which appends cognito 'sub' field for added security. In most cases the transformation to include/not include is transparent to the customer, but search is one of the areas that doesn't hold true. https://docs.amplify.aws/cli/migration/identity-claim-changes/#what-are-the-breaking-changes
We'll reproduce on our end, and see if this seems to be related to a substring search issue, or if we're able to repro the 'eq' issue as well.
Feature request has been opened here https://github.com/aws-amplify/amplify-category-api/issues/683
Hi, deployed the following schema.
type Student @model @auth(rules: [{ allow: owner, ownerField: "author" }]) @searchable {
name: String
author: String
}
performed a mutation and let AppSync auto assign owner.
mutation MyMutation {
createStudent(input: {name: "test1"}) {
author
createdAt
id
}
}
Outputs for searchable and list queries
Using format subID::ownername will work when using username as sign in method.
marking this as bug for improvements.
Has this been fixed/updated? Or is there another way to query just for user created items? It seems to me that this should be a no-brainer to have a way to filter/search items by the user who created them. Especially if users create an item, and want to view all their created items in a dashboard.
Very much would appreciate this, can't believe this is still not a thing and it took me a while to figure out why! For some reason the behaviour I've observed was that my query fetched the correct items on page refresh.... Anyway, a workable work-around seems to be (at least for my use case) to just have the field duplicated, once for auth and once for filtering, not amazing but oh well...
Before opening, please confirm:
How did you install the Amplify CLI?
No response
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
9.1.0
What operating system are you using?
Ubunutu Mate
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Amplify Categories
api
Amplify Commands
push
Describe the bug
When creating/updating a model and doing "amplify push", filters and inputs are not created for the automatically generated fields (createdAt, updatedAt, _version, _deleted, owner...).
I have a need in my app to be able to filter by owner and to create a new record in a lambda function as a specific owner.
Before I was accomplishing this by manually going into AppSync Schema any time I push and manually update the filters/inputs I need to add the owner field. This worked but was a bit cumbersome as I need to re-do these changes every time I push schema updates.
I then added
owner: ID
to the model definitions for models I needed this for and that added the inputs/filters I need.However, there is a strange behaivor when filtering by owner where doing a graphql "eq" comparsion returns no result but "match" or "beginsWith" does return the expected result.
Example: I have a searchable model called StudentInvitation
changing "eq" to "match" gives me my actual total count of 7
I have another model Profile with the same issue
changing to beginsWith for list operations works (list doesn't have "match")
Expected behavior
eq should work when filtering by owner
Reproduction steps
Create a model with
owner: ID
as one of the fields.Create a record and don't explicitly set the owner so it is set automatically.
Attempt to do a graphql list or search using the owner and the eq operation
GraphQL schema(s)
No response
Log output
No response
Additional information
No response