You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DataStore and API does not function properly with model names that start with lower case. For example, DataStore's subscriptions fail to be established, API's .create mutation helper fails.
Steps To Reproduce
Use an input schema where blog is lowercased
type Post @model{
id: ID!
title: String!
description: String
storageKey: String!
}
type blog @model {
id: ID!
title: String!
description: String
storageKey: String!
}
provision the API w/ conflict resolution to test against DataStore and API. (you can without conflict resolution to test against API only- some API GraphQL Builders will only work without conflict resolution enabled since update mutations requires version to be added to the request)
func createBlogAPI() {
let blog1 = blog(title: "title", description: "description", storageKey: "key")
Amplify.API.mutate(request: .create(blog1)) { event in
switch event {
case .success(let result):
switch result {
case .success(let blog1):
print("Successfully created blog1: \(blog1)")
case .failure(let error):
print("Got failed result with \(error.errorDescription)")
}
case .failure(let error):
print("Got failed event with error \(error)")
}
}
}
Will fail with
Got failed result with GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type UnknownType: Unknown type CreateblogInput", locations: Optional([Amplify.GraphQLError.Location(line: 1, column: 29)]), path: nil, extensions: nil), Amplify.GraphQLError(message: "Validation error of type FieldUndefined: Field \'createblog\' in type \'Mutation\' is undefined @ \'createblog\'", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: nil, extensions: nil)]
Starting DataStore will fail with
GraphQLResponseError<MutationSync<AnyModel>>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type FieldUndefined: Field \'onUpdateblog\' in type \'Subscription\' is undefined @ \'onUpdateblog\'", locations: nil, path: nil, extensions: nil)]
Expected behavior
The name should be capitalized in many different places here:
This has been open for awhile now and without any customer interaction. Searching for related issues, there's #274 and that has been resolved. The problem i described seems easy to work around and doesn't sound like any customer is running into this.
quick note -- I'm a customer and just ran into this today. Workaround was easy; just would have been nice to see explicit mention in docs of requiring upper case first letter model names
Was stumped by why a table randomly was throwing "Validation error of type UnknownType: Unknown type Create"; after finding this issue page, removing the table completely, running an "amplify push --allow-destructive-graphql-schema-updates
", then adding it back as ModelName and running another "amplify push" succeeded
Describe the bug
DataStore and API does not function properly with model names that start with lower case. For example, DataStore's subscriptions fail to be established, API's
.create
mutation helper fails.Steps To Reproduce
blog
is lowercasedprovision the API w/ conflict resolution to test against DataStore and API. (you can without conflict resolution to test against API only- some API GraphQL Builders will only work without conflict resolution enabled since update mutations requires version to be added to the request)
Will fail with
Expected behavior
The name should be capitalized in many different places here:
For queries, the name should be capitalized: https://github.com/aws-amplify/amplify-ios/blob/main/AmplifyPlugins/Core/AWSPluginsCore/Model/Support/ModelSchema+GraphQL.swift#L15
For Mutations as well https://github.com/aws-amplify/amplify-ios/blob/main/AmplifyPlugins/Core/AWSPluginsCore/Model/Support/ModelSchema+GraphQL.swift#L40
for Subscriptions as well https://github.com/aws-amplify/amplify-ios/blob/main/AmplifyPlugins/Core/AWSPluginsCore/Model/Support/ModelSchema+GraphQL.swift#L35
Amplify Framework Version
main
Amplify Categories
DataStore
Dependency manager
Cocoapods
Swift version
N/A
CLI version
N/A
Xcode version
12 / 13
Relevant log output
No response
Is this a regression? (i.e. was this working before a version upgrade)
No response
Device
N/A
iOS Version
N/A
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: