Skip to content
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

keyName / Resolver conflict #6472

Closed
sacrampton opened this issue Jan 24, 2021 · 4 comments
Closed

keyName / Resolver conflict #6472

sacrampton opened this issue Jan 24, 2021 · 4 comments
Labels
api-graphql Issues related to GraphQL resources in the API category feature-request Request a new feature pending-response Issue is pending response from the issue author

Comments

@sacrampton
Copy link

Describe the bug

In order to get DataStore to sync I had to change all of my connections from "@connection (name" to "@connection (keyName", but when compiling (amplify api gql-compile --minify) it throws an error if you do not have id as a mandatory field. So in the following connection statement, if I have "id:ID" it throws an error, but if I have "id:ID!" it does not.

  M2MConnection: [M2MConnection] @connection (keyName: "byM2MConnectionDocumentId", fields: ["id"])

Now here is where a problem arises. When creating a record we never provide an ID, we rely on the resolver to generate the ID as per the statement from the resolver below.

$util.qr($context.args.input.put("id", $util.defaultIfNull($ctx.args.input.id, $util.autoId())))

So what this means is that if you use a mutation and you don't provide an ID then the mutation fails.

There is a work around to this - get into the "input CreateModelInput" and remove the ! from the ID there - but this is a painful process when you have a lot of models.

Amplify CLI Version
4.41.2

To Reproduce
Defined above

Expected behavior
The gql-compile does not throw an error if the value is nullable - maybe a warning, but not an error

@ammarkarachi
Copy link
Contributor

@sacrampton We have merged a PR addressing the issue. Please take a look and let me know if this fits your use case.#5153

@ammarkarachi ammarkarachi added api-graphql Issues related to GraphQL resources in the API category enhancement pending-response Issue is pending response from the issue author labels Jan 25, 2021
@sacrampton
Copy link
Author

@ammarkarachi - I believe the core of my issue was allowing nullable fields so this should address it

@ammarkarachi
Copy link
Contributor

Cool! I will close this issue. The change should be available in the next release.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
@josefaidt josefaidt added feature-request Request a new feature and removed enhancement labels Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-graphql Issues related to GraphQL resources in the API category feature-request Request a new feature pending-response Issue is pending response from the issue author
Projects
None yet
Development

No branches or pull requests

3 participants