aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
89 stars 79 forks source link

id field is not of type string for model instead of ID #3044

Open djom202 opened 1 day ago

djom202 commented 1 day ago

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v20.12.0

Amplify CLI Version

12.13.1

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

My schema has at least 30 days deployed without changes, today I going to change something however when I pushed the changes I got this issue:

InvalidDirectiveError: geofenceVehicleId field is not of type String

Schema line before the change:

geofenceVehicleId: ID! @index(name: "byGeofence", sortKeyFields: ["name"])

So I revert the change in my Schema but I'm still getting the same issue, after that I decided to change the type of the geofenceVehicleId for String, therefor I got the next error message:

InvalidDirectiveError: id field is not of type String

My Schema in this moment:

type Vehicle @model @auth(rules: [{ allow: public }]) {
  id: ID!
}

I tried to change ID for String type and I can pushed the changes in a No-Prod environment and however I got this warning message:

This update will replace table(s) [VehicleTable]
ALL EXISTING DATA IN THESE TABLES WILL BE LOST!
If this is intended, rerun the command with '--allow-destructive-graphql-schema-updates'.

for that reason I cannot push the changes into my prod environment and I had to rollback all changes, and I still not have idea the reason why I got this error message.

I also want to highlight that this is the only one that gives me this error, while the other relationships are the same but do not have this particular issue.

Expected behavior

From my perspective, the schema should work as it did initially since I haven’t changed anything. However, I understand that a CLI update might have introduced changes, causing a new error like this. Ideally, the CLI should indicate what exactly I need to modify in my schema, specifying the exact line. Currently, it only mentions the attribute, and since I have many attributes with the same name, it’s difficult to pinpoint where the issue lies.

Reproduction steps

I suppose that the steps are related to the way how I setup the schema.

Project Identifier

Project Identifier: fb5b99268af59802a9999a876ab703cd

Log output

``` # Put your logs below this line ```

Additional information

No response

Before submitting, please confirm:

AnilMaktala commented 6 hours ago

Hey @djom202, Thanks for raising this. Could you provide some additional details about the specific change made to the schema that resulted in this error?

djom202 commented 5 hours ago

Hi @AnilMaktala, the point is that I didn't change anything. I pushed some new changes when I got the error message. After that, I rolled back those changes, but the error message didn't disappear. Since it doesn't seem to be related to the changes, I believe it could be a new check in the CLI.

bobbyu99 commented 5 hours ago

Hi @djom202, It seems like you pushed some changes, then you see the following error. After rolling back those changes, the following error still persist, is that correct? If so, could you share with us what's the changes that make the error first appear so we could have a bit more context?

InvalidDirectiveError: geofenceVehicleId field is not of type String
djom202 commented 5 hours ago

Yeah sure, I changed this:

type Vehicle @model @auth(rules: [{ allow: public }]) {
  id: ID!
  model_year: String!
....
 }

by this:

type Vehicle @model @auth(rules: [{ allow: public }]) {
  id: ID!
  modelYear: String!
....
 }