aws-amplify / aws-amplify/amplify-data

Build error "Type instantiation is excessively deep and possibly infinite."

Open
#521 7 comments 1 reaction 1 assignee Claimed by @chrisbonifacio View on GitHub
bug data-schema GraphQL
Dominant language
TypeScript
Stars
18
Forks
23
Avg merge
26m
Merged PRs (30d)
1

Description

### Before opening, please confirm:

- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-js/discussions).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### JavaScript Framework

Next.js

### Amplify APIs

GraphQL API

### Amplify Version

v6

### Amplify Categories

api

### Backend

Amplify Gen 2

### Environment information

```
# Put output below this line
System:
OS: macOS 15.1.1
CPU: (8) arm64 Apple M3
Memory: 259.19 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 9.15.0 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
Browsers:
Chrome: 131.0.6778.109
Safari: 18.1.1
npmPackages:
@aws-amplify/adapter-nextjs: 1.2.30 => 1.2.30
@aws-amplify/backend: 1.8.0 => 1.8.0
@aws-amplify/backend-cli: 1.4.2 => 1.4.2
@aws-amplify/ui-react: 6.7.1 => 6.7.1
@emotion/react: 11.13.5 => 11.13.5
@emotion/styled: 11.13.5 => 11.13.5
@fontsource/roboto: 5.1.0 => 5.1.0
@mui/icons-material: 6.1.10 => 6.1.10
@mui/material: 6.1.10 => 6.1.10
@reduxjs/toolkit: 2.4.0 => 2.4.0
@types/lodash.compact: 3.0.9 => 3.0.9
@types/lodash.uniq: 4.5.9 => 4.5.9
@types/node: 20.17.9 => 20.17.9
@types/react: 18.3.14 => 18.3.14
@types/react-dom: 18.3.2 => 18.3.2
aws-amplify: 6.10.2 => 6.10.2
aws-cdk: 2.172.0 => 2.172.0
aws-cdk-lib: 2.172.0 => 2.172.0
constructs: 10.4.2 => 10.4.2
dayjs: 1.11.13 => 1.11.13
decimal.js: 10.4.3 => 10.4.3
env-cmd: 10.1.0 => 10.1.0
envinfo: 7.14.0 => 7.14.0
esbuild: 0.24.0 => 0.24.0
lodash.compact: 3.0.1 => 3.0.1
lodash.uniq: 4.5.0 => 4.5.0
next: 14.2.20 => 14.2.20
prettier: 3.4.2 => 3.4.2
react: ^18 => 18.3.1
react-dom: ^18 => 18.3.1
react-redux: 9.1.2 => 9.1.2
tsx: 4.19.2 => 4.19.2
typescript: 5.7.2 => 5.7.2
uuid: 11.0.3 => 11.0.3
npmGlobalPackages:
corepack: 0.29.3
node-gyp: 10.2.0
npm: 10.8.2

```

### Describe the bug

I use the same selection set for `client.models.Foo.onUpdate` and `client.models.Foo.observeQuery`, the `observeQuery` cannot be build because of this error "Type error: Type instantiation is excessively deep and possibly infinite."

Local dev is working fine.

### Expected behavior

Project can be built.

### Reproduction steps

1. Create data models using `hasMany`, `oneOf`
2. Use `observeQuery`
3. Build the project

### Code Snippet

```typescript
// this works
useEffect(() => {
const sub = client.models.Store.onUpdate({
authMode: "userPool",
selectionSet: storeAdminSelectionSet,
}).subscribe({
next: (item) => {
dispatch(updateStore(item));
},
});

return () => sub.unsubscribe();
}, []);

// here build error: "Type error: Type instantiation is excessively deep and possibly infinite."
useEffect(() => {
const sub = client.models.Store.observeQuery({
authMode: "userPool",
selectionSet: storeAdminSelectionSet,
}).subscribe({
next: ({ items }: { items: StoreAdmin[] }) => {
dispatch(setStores([...items]));
},
});

return () => sub.unsubscribe();
}, []);

```

### Log output

```
// Put your logs below this line

```

### aws-exports.js

_No response_

### Manual configuration

_No response_

### Additional configuration

_No response_

### Mobile Device

_No response_

### Mobile Operating System

_No response_

### Mobile Browser

_No response_

### Mobile Browser Version

_No response_

### Additional information and screenshots

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.