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

Schema validation failed. There can be only one type named "EventInvocationResponse" #3100

Open
v-bilyavskiy opened this issue Dec 31, 2024 · 1 comment
Labels
bug Something isn't working Gen 2 transferred

Comments

@v-bilyavskiy
Copy link

Environment information

System:
  OS: macOS 15.2
  CPU: (8) arm64 Apple M1
  Memory: 108.17 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
  Yarn: undefined - undefined
  npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
  pnpm: 9.15.2 - ~/Library/pnpm/pnpm
NPM Packages:
  @aws-amplify/auth-construct: Not Found
  @aws-amplify/backend: 1.11.0
  @aws-amplify/backend-auth: 1.4.2
  @aws-amplify/backend-cli: 1.4.5
  @aws-amplify/backend-data: Not Found
  @aws-amplify/backend-deployer: Not Found
  @aws-amplify/backend-function: 1.10.0
  @aws-amplify/backend-output-schemas: Not Found
  @aws-amplify/backend-output-storage: Not Found
  @aws-amplify/backend-secret: Not Found
  @aws-amplify/backend-storage: 1.2.4
  @aws-amplify/cli-core: Not Found
  @aws-amplify/client-config: Not Found
  @aws-amplify/deployed-backend-client: Not Found
  @aws-amplify/form-generator: Not Found
  @aws-amplify/model-generator: Not Found
  @aws-amplify/platform-core: 1.4.0
  @aws-amplify/plugin-types: 1.6.0
  @aws-amplify/sandbox: Not Found
  @aws-amplify/schema-generator: Not Found
  aws-amplify: 6.11.0
  aws-cdk: 2.173.0
  aws-cdk-lib: 2.173.0
  typescript: 5.7.2
No AWS environment variables
No CDK environment variables

Describe the bug

When using a.combine() and having a.handler.function(...).async() in each scheme, the following error:

cause: SchemaValidationError: Schema validation failed.
  
  There can be only one type named "EventInvocationResponse".
  
  GraphQL request:5:6
  4 |
  5 | type EventInvocationResponse @aws_cognito_user_pools {
    |      ^
  6 |   success: Boolean!
  
  GraphQL request:98:6
  97 |
  98 | type EventInvocationResponse @aws_cognito_user_pools {
     |      ^
  99 |   success: Boolean!
  
  Field "EventInvocationResponse.success" can only be defined once.
  
  GraphQL request:6:3
  5 | type EventInvocationResponse @aws_cognito_user_pools {
  6 |   success: Boolean!
    |   ^
  7 | }
  
  GraphQL request:99:3
   98 | type EventInvocationResponse @aws_cognito_user_pools {
   99 |   success: Boolean!
      |   ^
  100 | }
  
  The directive "@aws_cognito_user_pools" can only be used once at this location.
  
  GraphQL request:5:30
  4 |
  5 | type EventInvocationResponse @aws_cognito_user_pools {
    |                              ^
  6 |   success: Boolean!
  
  GraphQL request:98:30
  97 |
  98 | type EventInvocationResponse @aws_cognito_user_pools {
     |                              ^
  99 |   success: Boolean!

In my opinion, the problem is that for each of the schemes a type with the same name is added, and when merging the schemas, duplicates arise.

https://github.com/aws-amplify/amplify-data/blob/2394f64dc37eeda0f6a48876ec8d22709662c2a7/packages/data-schema/src/SchemaProcessor.ts#L1345-L1362
https://github.com/aws-amplify/amplify-data/blob/2394f64dc37eeda0f6a48876ec8d22709662c2a7/packages/data-schema/src/CustomOperation.ts#L361-L371

Reproduction steps

const schema = a.combine([
  a.schema({
    mutation1: a
      .mutation()
      .arguments({
        ...
      })
      .handler(
        a.handler.function(handler1).async(),
      )
      .authorization(allow => [
        ...
      ]),
  }),
  a.schema({
    mutation2: a
      .mutation()
      .arguments({
        ...
      })
      .handler(
        a.handler.function(handler2).async(),
      )
      .authorization(allow => [
        ...
      ]),
  }),
])

export const data = defineData({
  schema,
})
@ykethan
Copy link
Member

ykethan commented Dec 31, 2024

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Dec 31, 2024
@AnilMaktala AnilMaktala added bug Something isn't working and removed pending-triage labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Gen 2 transferred
Projects
None yet
Development

No branches or pull requests

3 participants