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

Amplify.API.query with Request .list() and .paginatedList() falis with FieldUndefined and not using pluralName of the table from generated Table+Schema.swift #1419

Closed
maremoto opened this issue Sep 11, 2021 · 5 comments
Assignees
Labels
api Issues related to the API category bug Something isn't working pending-release Code has been merged but pending release Code has been merged but pending release

Comments

@maremoto
Copy link

maremoto commented Sep 11, 2021

Describe the bug

When trying to list a full table with Amplify.API and the table has a name that is a plural, the generated code in Tablename+Schema.swift recognizes that the plural name is the same as the table and declares it properly:

Example, tablename = "Wishes", then at generated code Wishes+Schema.swift you see:

model.pluralName = "Wishes"

But when using IOS SDK and executing an Amplify.API.query call with request .list() or .paginatedList() it fails with this error:

failure(GraphQLResponseError<Array<Posts>>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type FieldUndefined: Field \'**listWishess**\' in type \'Query\' is undefined @ \'**listWishess**\'", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: nil, extensions: nil)]

Steps To Reproduce

Steps to reproduce the behavior:
1. Create a table (@model) with a plural name e.g. "Wishes"
2. Using IOS SDK try to list the table with Amplify.API.query function
3. See error

Expected behavior

Working properly and using pluralName var.

Amplify Framework Version

1.12.1

Amplify Categories

API

Dependency manager

Cocoapods

Swift version

5.0

CLI version

5.5.0

Xcode version

12.5

Relevant log output

failure(GraphQLResponseError<Array<Posts>>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type FieldUndefined: Field \'listWishess\' in type \'Query\' is undefined @ \'Wishess\'", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: nil, extensions: nil)]

Is this a regression? (i.e. was this working before a version upgrade)

No

Device

IPoneSE and Simulator

iOS Version

IOS 13.0

Specific to simulators

No response

Additional context

type Wishes @model 
@key(name: "byUsers", fields: ["idUser"]) 
@auth(rules: [{allow: owner}, 
{allow: private, operations: [create]}]) {

  id: ID!
  date: AWSDateTime!
  idUser: ID!
  ev: ID! 
  deprecated: Boolean!  # needed for logical deletion, as no real deletion exists
  owner: String         # needed as current IOS SDK do not insert it
}
@diegocstn diegocstn added the api Issues related to the API category label Sep 20, 2021
@lawmicha lawmicha added bug Something isn't working pending-triage Issue is pending triage labels Sep 30, 2021
@lawmicha lawmicha self-assigned this Oct 1, 2021
@lawmicha
Copy link
Member

lawmicha commented Oct 3, 2021

Hi @maremoto, thanks for opening this issue, it looks like the library is not compatible with the latest Amplify CLI provisioning of the list query. The investigation can be followed here: aws-amplify/amplify-cli#8350 The workaround right now may be to downgrade to use the provisioning done by the CLI before 5.0.2 which will generate a different list query name, which the library is aligned on.

@lawmicha lawmicha added follow up Requires follow up from maintainers and removed pending-triage Issue is pending triage labels Oct 3, 2021
@sebsto
Copy link

sebsto commented Oct 4, 2021

my workaround at the moment is to comment out the .pluralize()call at line 19 here
https://github.com/aws-amplify/amplify-ios/blob/v1.14.0/AmplifyPlugins/Core/AWSPluginsCore/Model/Support/ModelSchema%2BGraphQL.swift#L19

@lawmicha
Copy link
Member

lawmicha commented Oct 4, 2021

An easier way to bypass this is to set the feature flag to false

The feature flag to turn off this pluralization is features.graphqltransformer.improvepluralization in your project's amplify/cli.json file.

aws-amplify/amplify-cli#8350 (comment)

@lawmicha
Copy link
Member

lawmicha commented Oct 29, 2021

@lawmicha lawmicha added pending-release Code has been merged but pending release Code has been merged but pending release and removed follow up Requires follow up from maintainers labels Oct 29, 2021
@lawmicha
Copy link
Member

please track this issue for the same resolution #1443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API category bug Something isn't working pending-release Code has been merged but pending release Code has been merged but pending release
Projects
None yet
Development

No branches or pull requests

4 participants