aws-amplify / aws-amplify/amplify-data
Callstack size exceeded on one to many relationship with `customType`s
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 23
- Avg merge
- 26m
- Merged PRs (30d)
- 1
Description
### Environment information
```plain text
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 4.40 GB / 31.74 GB
Binaries:
Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
Yarn: 4.3.1 - C:\Program Files\nodejs\yarn.CMD
npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.13.1 - C:\Program Files\nodejs\pnpm.CMD
NPM Packages:
@aws-amplify/auth-construct: 1.5.0
@aws-amplify/backend: 1.7.0
@aws-amplify/backend-auth: 1.4.0
@aws-amplify/backend-cli: 1.4.2
@aws-amplify/backend-data: 1.2.0
@aws-amplify/backend-deployer: 1.1.9
@aws-amplify/backend-function: 1.7.5
@aws-amplify/backend-output-schemas: 1.4.0
@aws-amplify/backend-output-storage: 1.1.3
@aws-amplify/backend-secret: 1.1.5
@aws-amplify/backend-storage: 1.2.2
@aws-amplify/cli-core: 1.2.0
@aws-amplify/client-config: 1.5.2
@aws-amplify/deployed-backend-client: 1.4.2
@aws-amplify/form-generator: 1.0.3
@aws-amplify/model-generator: 1.0.9
@aws-amplify/platform-core: 1.2.0
@aws-amplify/plugin-types: 1.4.0
@aws-amplify/sandbox: 1.2.5
@aws-amplify/schema-generator: 1.2.5
aws-amplify: 6.8.2
aws-cdk: 2.166.0
aws-cdk-lib: 2.167.0
typescript: 5.6.3
AWS environment variables:
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables
```
### Data packages
```plain text
nuxt-app@ M:\source\AdvancedStorageV3
├─┬ @aws-amplify/backend-cli@1.4.2
│ └─┬ @aws-amplify/schema-generator@1.2.5
│ └── @aws-amplify/graphql-schema-generator@0.11.2
└─┬ @aws-amplify/backend@1.7.0
└─┬ @aws-amplify/backend-data@1.2.0
└── @aws-amplify/data-construct@1.13.2
```
### Description
TLDR - pushing out a deployment to sandbox causes a error when:
There is a one to many relationship between two customType()s using a.ref() & a.ref().array()
There is a 3rd model table using a.model()
A custom query references the a.model() table as dataSource and one of the a.customTypes() as returns() value.
Error Message:
```
Maximum call stack size exceeded
Caused By: Maximum call stack size exceeded
Resolution: Check your data schema definition for syntax and type errors.
```
Schema:
```
const schema = a.schema({
MasterTenantTable: a.model({
pk: a.string().required(),
sk: a.string().required(),
company_id: a.id(),
})
.authorization(allow=> [allow.publicApiKey()]),
Tenant: a.customType({
company: a.ref('Company'),
company_id: a.id().required(),
}),
Company: a.customType({
tenants: a.ref('Tenant').array(),
}),
getCompanyById: a.query()
.arguments({company_id: a.id().required()})
.returns(a.ref('Tenant').array())
.authorization(allow=> [allow.authenticated()])
.handler(a.handler.custom({
dataSource: a.ref('MasterTenantTable'),
entry: './company-resolvers/getCompanyById.js',
})),
});
```
Repo reproduction link:
https://github.com/jmarshall9120/AmplifySchemaTesting
Contributor guide
Assessment
This issue has not been assessed yet.