Open sbelbin opened 4 months ago
Hi @sbelbin, this fails because dashes are not valid enum values in the GraphQL spec. However, as you mention there is an opportunity to throw a more descriptive error message in this case. Marking as a feature request to improve the error message.
Environment information
Description
In amplify/data/resource.ts file, I defined a field having an enumeration types in which put string values.
const schema = a.schema({ Downloads: a .model({ ... kind: a.enum(['aws-s3', 'azure-blob']),
However, when a string value contains the hyphen - character the error during the generator phase is cryptic (see below). For some reason the generation phase is attempting to perform an mathematical operation on the enumeration strings.AmplifyError [InvalidSchemaError]: Syntax Error: Invalid number, expected digit but got: "s". 58 at DataGenerator.generateContainerEntry (/codebuild/output/src3878792534/src/amplify-vite-react-template/node_modules/@aws-amplify/backend-data/src/factory.ts:165:13)
Fortunately, I can workaround this by replacing hyphen - character by an underscore _.
However, this is a bug during parsing of the enumeration values.
P.S. I'll state that the failure of the error messages not providing the text or line numbers which fail to parse made the experience that much more unpleasant. Especially since "s" is rather a common letter.