amplify-category-api
amplify-category-api copied to clipboard
Schema validation failed. There can be only one type named "EventInvocationResponse"
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,
})