-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional relation forced #3077
Comments
Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂 |
Hi @Lisciowsky, thanks for raising the issue! We'll investigate and see what's going on, and get back to you once we have a solution. |
Hi @Lisciowsky 👋 A few questions to better understand the issue described.
in the meantime, as a potential workaround, you could try omitting the entire i'm not sure what the non-nullable fields on createFile(input: $input, condition: $condition) {
id
ownerEmail
createdAt
updatedAt
fileName
filePath
storeID
store {
ownerEmail
name
__typename
}
__typename
}
} |
Hello,
It is forced because the createFile mutation does include the [optional] store, and without providing it, it causes the error as you have mentioned.
Yes I can confirm, I had to compare on 2 separate environemnts DEV (created with newest version of amplify cli) and STAGE with (12.1.0) DEV:
STAGE:
This is CGPT comment:
Can you share the schema for both File and Storage so we can reproduce the issue as closely to your setup as possible? It might help identify any issues related to non-obvious things like auth rules as well. You can replicate this one easily as long as you have one to many with @belongsTo ans @hasmany directives on the one-to-many model relation. Here is the example grapqhl schema definition:
Just to summarize, the newest version of the aws cli does create the resolvers but they force the File (following the example schema above) to ensure it points to the store. Your tempfix would certainly work (not including the store in the grapqhl). I do not want to modify the auto-generated amplify queries OR resolvers OR subscriptions and I believe nobody wants to every time I code gen or make some changes. Then I would end up in a scenario where a file without an associated store would have to use a different query, that's just bad news. PS: The resolver differences on DEV & STAGE example were taken from different project but the issue is exactly the same. I hope it helps you to fix this, or perhaps roll back the changes that impact the resolver creation PS2: I just reminded myself that it gets even worse, I think even if you provide the storeID while creating the file it still is unable to resolve the store. At least that was the case for me with the exactly same schema generated via newest amplify-cli version vs 12.1.0 which worked correctly. For both of the cases I have changed the amplify version to 12.1.0 recreated the environment and everything works like a charm |
How did you install the Amplify CLI?
npm install -g @aws-amplify/cli
If applicable, what version of Node.js are you using?
v18.20.3
Amplify CLI Version
12.13.1
What operating system are you using?
ubuntu 22.04
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
no manual changes
Describe the bug
createFile mutation variables:
"fileName": "text_file",
"filePath": "/random_user/text_file",
"ownerEmail": "test@o2.pl",
"storeID": "3afa26ba-b30f-405e-aee6-804a9a9c19a6"
With the newest version of amplify it is not possible to resolve the Store, I had to dump the version of the amplify cli so that the created resolvers would understand that store can be associated with a file but doesn't have to and if the store id is given during the file creation mutation it then can resolve the actual store.
You have a serious problem with hasMany and belongs to directive, no doubt about that.
Expected behavior
I expected to have successful graphql call during file creation mutation with or without providing the existing associated store id with the newest version of amplify cli. This isn't the case
Reproduction steps
If you would like to reproduce the bug just install the newest aws cli and then create two models
one model will have
storeID: ID
store: Store @belongsTo(fields: ["storeID"])
another model will have:
files: [File] @hasmany(fields: ["id"])
And try to create the file without specifying the store in this example, or omitting it completely.
I am forced to use the older version 12.1.0 which created the "reasonable" resolvers.
Project Identifier
No response
Log output
Additional information
N/A
Before submitting, please confirm:
The text was updated successfully, but these errors were encountered: