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

Error in pluralization GraphQL Transform code or codegen #1443

Closed
sebsto opened this issue Sep 29, 2021 · 7 comments
Closed

Error in pluralization GraphQL Transform code or codegen #1443

sebsto opened this issue Sep 29, 2021 · 7 comments
Assignees
Labels
api Issues related to the API category bug Something isn't working

Comments

@sebsto
Copy link

sebsto commented Sep 29, 2021

Describe the bug

Hello team,

I am following instructions provided by the Amplify iOS tutorial here

I am running into a strange error with the GraphQL API.

This call in the iOS app
Amplify.API.query(request: .list(NoteData.self)) { event in ...
causes this error
error GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type FieldUndefined: Field \'listNoteDatas\' in type \'Query\' is undefined @ \'listNoteDatas\'", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: nil, extensions: nil)]

Notice the listNoteDatas has an extra “s” at the end. The query, as seen from AppSync console, does not have that and
it works in the console.

query MyQuery {
  listNoteData {
    items {
      createdAt
      description
      id
      image
      name
      owner
      updatedAt
    }
  }
}

The schema is

type NoteData
@model
@auth (rules: [ { allow: owner } ]) {
    id: ID!
    name: String!
    description: String
    image: String
}

I am testing with Amplify CLI 6.1.0 on macOS
I think this is a regression from Amplify 5.x

Amplify API Plugin 1.14.0

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create an API with schema
type NoteData
@model
@auth (rules: [ { allow: owner } ]) {
    id: ID!
    name: String!
    description: String
    image: String
}
  1. Write a function to query all notes
Amplify.API.query(request: .list(NoteData.self)) { event in ...
  1. Build and Run

Expected behavior

The query should return all notes

Amplify Framework Version

1.14.0

Amplify Categories

API

Dependency manager

Cocoapods

Swift version

5.5

CLI version

6.1.0

Xcode version

13

Relevant log output

error  GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type FieldUndefined: Field \'listNoteDatas\' in type \'Query\' is undefined @ \'listNoteDatas\'", 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)

Yes.

Device

iOS Simulator

iOS Version

15

Specific to simulators

No response

Additional context

No response

@sebsto sebsto changed the title Error in pluralization GraphQL Transform code or coding Error in pluralization GraphQL Transform code or codgen Sep 29, 2021
@sebsto sebsto changed the title Error in pluralization GraphQL Transform code or codgen Error in pluralization GraphQL Transform code or codegen Sep 29, 2021
@lawmicha lawmicha added api Issues related to the API category 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 @sebsto, 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 that the library is aligned on.

@sebsto
Copy link
Author

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 lawmicha added follow up Requires follow up from maintainers and removed pending-triage Issue is pending triage labels Oct 22, 2021
@lawmicha
Copy link
Member

related: #1451

@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

lawmicha commented Oct 29, 2021

@lawmicha
Copy link
Member

Please track #3135

@github-actions github-actions bot removed the pending-release Code has been merged but pending release Code has been merged but pending release label Aug 10, 2023
@lawmicha
Copy link
Member

lawmicha commented Sep 8, 2023

Please use Amplify CLI 12.4.0 or greater to get the fix for the pluralization issue

sebsto added a commit to sebsto/amplify-ios-getting-started that referenced this issue Sep 8, 2023
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
Projects
None yet
Development

No branches or pull requests

2 participants