Skip to content

Nested Custom Types generate invalid code #952

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

Open
3 tasks done
csmith-rtr opened this issue Mar 14, 2025 · 5 comments
Open
3 tasks done

Nested Custom Types generate invalid code #952

csmith-rtr opened this issue Mar 14, 2025 · 5 comments
Labels
bug Something isn't working Gen 2

Comments

@csmith-rtr
Copy link

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

GraphQL API

Amplify Version

v6

Amplify Categories

api

Backend

Amplify Gen 2

Environment information

  System:
    OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz
    Memory: 42.62 GB / 93.51 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 22.14.0 - /usr/bin/node
    npm: 10.9.2 - /usr/bin/npm
  Browsers:
    Chrome: 133.0.6943.141
    Chromium: 134.0.6998.35
  npmPackages:
    @ampproject/toolbox-optimizer:  undefined ()
    @anatine/zod-mock: ^3.13.4 => 3.13.4 
    @aws-amplify/adapter-nextjs: ^1.2.32 => 1.2.32 
    @aws-amplify/adapter-nextjs/api:  undefined ()
    @aws-amplify/adapter-nextjs/data:  undefined ()
    @aws-amplify/backend: ^1.14.1 => 1.14.1 
    @aws-amplify/backend-cli: ^1.4.12 => 1.4.12 
    @aws-amplify/ui-react: ^6.7.1 => 6.7.1 
    @aws-amplify/ui-react-internal:  undefined ()
    @aws-amplify/ui-react-server:  undefined ()
    @aws-appsync/eslint-plugin: ^1.10.1 => 1.10.1 
    @aws-appsync/utils: ^1.10.1 => 1.10.1 
    @aws-lambda-powertools/logger: ^2.13.0 => 2.13.0 
    @aws-sdk/client-cognito-identity-provider: ^3.620.1 => 3.620.1 
    @aws-sdk/client-dynamodb: ^3.614.0 => 3.614.0 
    @aws-sdk/client-ecs: ^3.596.0 => 3.596.0 
    @aws-sdk/client-eventbridge: ^3.637.0 => 3.637.0 
    @aws-sdk/client-servicediscovery: ^3.609.0 => 3.609.0 
    @aws-sdk/client-sns: ^3.679.0 => 3.679.0 
    @aws-sdk/lib-dynamodb: ^3.614.0 => 3.614.0 
    @aws-sdk/smithy-client: ^3.374.0 => 3.374.0 
    @babel/core:  undefined ()
    @babel/runtime:  7.22.5 
    @codemirror/autocomplete: ^6.0.1 => 6.9.0 
    @codemirror/language: ^6.0.0 => 6.8.0 
    @codemirror/legacy-modes: ^6.0.0 => 6.3.3 
    @codemirror/lint: ^6.0.0 => 6.4.0 
    @cypress/angular:  0.0.0-development 
    @cypress/angular-signals:  0.0.0-development 
    @cypress/code-coverage: ^3.13.1 => 3.13.1 
    @cypress/mount-utils:  0.0.0-development 
    @cypress/react:  0.0.0-development 
    @cypress/react18:  0.0.0-development 
    @cypress/svelte:  0.0.0-development 
    @cypress/vue:  0.0.0-development 
    @cypress/vue2:  0.0.0-development 
    @cypress/webpack-dev-server: 3.9.0 => 3.9.0 
    @dagrejs/dagre: ^1.1.4 => 1.1.4 
    @dnd-kit/core: ^6.0.8 => 6.0.8 
    @dnd-kit/modifiers: ^6.0.1 => 6.0.1 
    @dnd-kit/sortable: ^7.0.2 => 7.0.2 
    @edge-runtime/cookies:  4.1.1 
    @edge-runtime/ponyfill:  2.4.2 
    @edge-runtime/primitives:  4.1.0 
    @faker-js/faker: ^9.0.3 => 9.0.3 
    @floating-ui/react: ^0.25.1 => 0.25.1 (0.26.13)
    @hapi/accept:  undefined ()
    @headlessui/react: ^2.0.3 => 2.0.3 
    @headlessui/tailwindcss: ^0.2.0 => 0.2.0 
    @hookform/error-message: ^2.0.1 => 2.0.1 
    @hookform/resolvers: ^3.9.1 => 3.9.1 
    @hookform/resolvers/ajv:  1.0.0 
    @hookform/resolvers/arktype:  2.0.0 
    @hookform/resolvers/class-validator:  1.0.0 
    @hookform/resolvers/computed-types:  1.0.0 
    @hookform/resolvers/effect-ts:  1.0.0 
    @hookform/resolvers/fluentvalidation-ts:  1.0.0 
    @hookform/resolvers/io-ts:  1.0.0 
    @hookform/resolvers/joi:  1.0.0 
    @hookform/resolvers/nope:  1.0.0 
    @hookform/resolvers/superstruct:  1.0.0 
    @hookform/resolvers/typanion:  1.0.0 
    @hookform/resolvers/typebox:  1.0.0 
    @hookform/resolvers/typeschema:  1.0.0 
    @hookform/resolvers/valibot:  1.0.0 
    @hookform/resolvers/vest:  1.0.0 
    @hookform/resolvers/vine:  1.0.0 
    @hookform/resolvers/yup:  1.0.0 
    @hookform/resolvers/zod:  1.0.0 
    @jsonforms/core: ^3.0.0 => 3.1.0 
    @jsonforms/react: ^3.0.0 => 3.1.0 
    @jsonforms/vanilla-renderers: ^3.0.0 => 3.1.0 
    @monaco-editor/react: ^4.6.0 => 4.6.0 
    @mswjs/interceptors:  undefined ()
    @napi-rs/triples:  undefined ()
    @next/font:  undefined ()
    @number-flow/react: ^0.3.0 => 0.3.0 
    @nx-extend/shadcn-ui: ^4.2.0 => 4.2.0 
    @nx/cypress: 20.1.2 => 20.1.2 
    @nx/devkit: 20.1.2 => 20.1.2 (20.0.0)
    @nx/esbuild: 20.1.2 => 20.1.2 
    @nx/eslint: 20.1.2 => 20.1.2 (20.0.0)
    @nx/eslint-plugin: 20.1.2 => 20.1.2 
    @nx/express: 20.1.2 => 20.1.2 
    @nx/jest: 20.1.2 => 20.1.2 
    @nx/js: 20.1.2 => 20.1.2 (20.0.0)
    @nx/next: 20.1.2 => 20.1.2 
    @nx/node: 20.1.2 => 20.1.2 
    @nx/plugin: 20.1.2 => 20.1.2 
    @nx/react: 20.1.2 => 20.1.2 
    @nx/storybook: 20.1.2 => 20.1.2 
    @nx/vite: 20.1.2 => 20.1.2 
    @nx/web: 20.1.2 => 20.1.2 
    @nx/webpack: 20.1.2 => 20.1.2 
    @nx/workspace: 20.1.2 => 20.1.2 (20.0.0)
    @opentelemetry/api:  undefined ()
    @radix-ui/react-avatar: ^1.1.2 => 1.1.2 
    @radix-ui/react-checkbox: ^1.1.3 => 1.1.3 
    @radix-ui/react-context-menu: ^2.2.4 => 2.2.4 
    @radix-ui/react-dialog: ^1.1.2 => 1.1.2 
    @radix-ui/react-dropdown-menu: ^2.1.2 => 2.1.2 (1.0.0)
    @radix-ui/react-hover-card: ^1.1.1 => 1.1.1 
    @radix-ui/react-label: ^2.1.0 => 2.1.0 
    @radix-ui/react-popover: ^1.1.1 => 1.1.1 
    @radix-ui/react-progress: ^1.1.0 => 1.1.0 
    @radix-ui/react-radio-group: ^1.2.2 => 1.2.2 
    @radix-ui/react-scroll-area: ^1.1.0 => 1.1.0 
    @radix-ui/react-select: ^2.1.2 => 2.1.2 
    @radix-ui/react-slider: ^1.2.1 => 1.2.1 (1.0.0)
    @radix-ui/react-slot: ^1.1.0 => 1.1.0 (1.0.0, 1.1.1)
    @radix-ui/react-switch: ^1.1.1 => 1.1.1 
    @radix-ui/react-toast: ^1.2.1 => 1.2.1 
    @radix-ui/react-tooltip: ^1.1.2 => 1.1.2 
    @react-aria/interactions: ^3.14.0 => 3.21.1 
    @react-spring/three: ^9.7.3 => 9.7.3 (9.6.1)
    @react-three/drei: ^9.66.1 => 9.79.4 
    @react-three/fiber: ^8.12.0 => 8.13.5 
    @realtime-robotics/resolver-schema: ^1.3.3 => 1.3.3 
    @statsig/react-bindings: ^3.2.0 => 3.2.0 
    @statsig/web-analytics: ^3.2.0 => 3.2.0 
    @storybook/addon-essentials: ^8.2.8 => 8.4.7 
    @storybook/core-server: ^8.2.8 => 8.4.7 
    @storybook/nextjs: ^8.2.8 => 8.4.7 
    @swc-node/register: 1.9.2 => 1.9.2 
    @swc/cli: 0.3.14 => 0.3.14 
    @swc/core: 1.5.7 => 1.5.7 
    @swc/helpers: 0.5.13 => 0.5.13 (0.5.5)
    @tailwindcss/container-queries: ^0.1.1 => 0.1.1 
    @tailwindcss/forms: ^0.5.2 => 0.5.4 
    @tanstack/query-codemods:  4.24.3 
    @tanstack/query-sync-storage-persister: ^5.32.0 => 5.32.0 
    @tanstack/react-query: ^5.0.0 => 5.32.0 
    @tanstack/react-query-persist-client: ^5.32.0 => 5.32.0 
    @tanstack/react-table: ^8.20.5 => 8.20.5 
    @testcontainers/localstack: ^10.18.0 => 10.18.0 
    @testing-library/react: 15.0.6 => 15.0.6 
    @testing-library/user-event: ^13.5.0 => 13.5.0 (14.5.2)
    @tippyjs/react: ^4.2.6 => 4.2.6 
    @types/busboy: ^1.5.0 => 1.5.0 
    @types/express: 4.17.14 => 4.17.14 (4.17.21)
    @types/express-http-proxy: 1.6.1 => 1.6.1 
    @types/jest: 29.5.14 => 29.5.14 
    @types/jsonwebtoken: ^9.0.8 => 9.0.8 
    @types/jwk-to-pem: ^2.0.3 => 2.0.3 
    @types/lodash: ^4.14.182 => 4.14.195 
    @types/luxon: ^3.3.3 => 3.3.3 
    @types/multiparty: 0.0.32 => 0.0.32 
    @types/node: 18.19.31 => 18.19.31 (22.10.2)
    @types/object-hash: ^3.0.2 => 3.0.2 
    @types/ping: 0.2.0 => 0.2.0 
    @types/react: 18.3.1 => 18.3.1 
    @types/react-dom: 18.3.0 => 18.3.0 
    @types/react-syntax-highlighter: ^15.5.6 => 15.5.7 
    @types/supertest: ^2.0.12 => 2.0.12 
    @types/swagger-jsdoc: ^6.0.1 => 6.0.1 
    @types/swagger-ui-express: ^4.1.3 => 4.1.3 
    @types/temp: 0.8.34 => 0.8.34 
    @types/three: ^0.150.0 => 0.150.2 
    @types/unzipper: ^0.10.10 => 0.10.10 
    @types/uuid: ^10.0.0 => 10.0.0 (9.0.8)
    @types/ws: ^7.4.0 => 7.4.7 (8.5.14, 8.5.5)
    @typescript-eslint/eslint-plugin: 7.18.0 => 7.18.0 
    @typescript-eslint/parser: 7.18.0 => 7.18.0 (6.21.0)
    @uiw/codemirror-themes: ^4.21.2 => 4.21.8 
    @uiw/react-codemirror: ^4.8.1 => 4.21.8 
    @vercel/nft:  undefined ()
    @vercel/og:  0.6.2 
    @vitejs/plugin-react: 4.2.1 => 4.2.1 
    @vitest/coverage-v8: 1.5.3 => 1.5.3 
    @xyflow/react: ^12.4.4 => 12.4.4 
    acorn:  undefined ()
    amphtml-validator:  undefined ()
    anser:  undefined ()
    arg:  undefined ()
    assert:  undefined ()
    async-retry:  undefined ()
    async-sema:  undefined ()
    autoprefixer: 10.4.13 => 10.4.13 
    aws-amplify: ^6.13.1 => 6.13.1 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/adapter-core/internals:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/internals:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    aws-cdk-lib: ^2.165.0 => 2.182.0 
    axios: 1.6.8 => 1.6.8 (1.7.9, 1.7.7)
    babel-packages:  undefined ()
    babel-plugin-istanbul: ^7.0.0 => 7.0.0 (6.1.1)
    browserify-zlib:  undefined ()
    browserslist:  undefined ()
    bsd-3-module:  0.0.0 
    buffer:  undefined ()
    busboy: ^1.6.0 => 1.6.0 
    bytes:  undefined ()
    cbor-x: ^1.6.0 => 1.6.0 
    ci-info:  undefined ()
    class-variance-authority: ^0.7.0 => 0.7.0 
    cli-select:  undefined ()
    client-only:  0.0.1 
    clsx: ^2.1.1 => 2.1.1 (1.2.1, 2.0.0, 2.1.0)
    comlink: ^4.4.1 => 4.4.1 
    commander:  undefined ()
    comment-json:  undefined ()
    compression:  undefined ()
    conf:  undefined ()
    constants-browserify:  undefined ()
    constructs: ^10.4.2 => 10.4.2 
    content-disposition:  undefined ()
    content-type:  undefined ()
    cookie:  undefined ()
    core-js: ^3.37.0 => 3.37.0 (2.6.12)
    cors: 2.8.5 => 2.8.5 
    cross-spawn:  undefined ()
    crypto-browserify:  undefined ()
    css-loader: ^6.4.0 => 6.8.1 
    css.escape:  undefined ()
    custom-license:  0.0.0 
    cypress: ^13.17.0 => 13.17.0 
    cypress-terminal-report: ^7.0.3 => 7.0.3 
    data-uri-to-buffer:  undefined ()
    date-fns: ^4.1.0 => 4.1.0 
    debug:  undefined ()
    devalue:  undefined ()
    docusaurus:  0.0.0 
    domain-browser:  undefined ()
    edge-runtime:  undefined ()
    esbuild: ^0.19.2 => 0.19.12 (0.25.1, 0.20.2)
    eslint: 8.57.0 => 8.57.0 
    eslint-config-next: 14.2.3 => 14.2.3 
    eslint-config-prettier: 9.0.0 => 9.0.0 
    eslint-formatter-gitlab: ^5.1.0 => 5.1.0 
    eslint-plugin-cypress: 2.15.1 => 2.15.1 
    eslint-plugin-import: 2.31.0 => 2.31.0 
    eslint-plugin-jsx-a11y: 6.10.1 => 6.10.1 
    eslint-plugin-react: 7.35.0 => 7.35.0 
    eslint-plugin-react-hooks: 5.0.0 => 5.0.0 (5.0.0-canary-7118f5dd7-20230705)
    events:  undefined ()
    express: 4.18.2 => 4.18.2 (4.21.2)
    find-cache-dir:  undefined ()
    find-up:  undefined ()
    flat: ^6.0.1 => 6.0.1 (5.0.2)
    framer-motion: ^11.11.11 => 11.11.11 
    fresh:  undefined ()
    fuse.js: ^6.6.2 => 6.6.2 
    get-orientation:  undefined ()
    glob: ^10.3.3 => undefined (7.2.3, 10.4.5, 10.3.10, , 7.1.6, 8.1.0)
    gzip-size:  undefined ()
    html-webpack-plugin: ^5.5.0 => 5.6.0 
    http-proxy:  undefined ()
    http-proxy-agent:  undefined ()
    http-proxy-middleware: ^2.0.6 => 2.0.6 (3.0.3, 2.0.7)
    https-browserify:  undefined ()
    https-proxy-agent:  undefined ()
    husky: ^8.0.0 => 8.0.3 
    icss-utils:  undefined ()
    ignore-loader:  undefined ()
    image-size:  undefined ()
    immer: ^10.0.2 => 10.0.2 (9.0.21, 9.0.6)
    invalid-with-comma:  0.0.0 
    is-animated:  undefined ()
    is-docker:  undefined ()
    is-wsl:  undefined ()
    jest: 29.7.0 => 29.7.0 
    jest-environment-jsdom: 29.7.0 => 29.7.0 
    jest-environment-node: ^29.4.1 => 29.7.0 
    jest-worker:  undefined ()
    jsdom: 22.1.0 => 22.1.0 (20.0.3)
    json5:  undefined ()
    jsonwebtoken: ^9.0.2 => undefined (9.0.2, )
    jszip: ^3.10.1 => 3.10.1 
    junit-merge: ^2.0.0 => 2.0.0 
    jwk-to-pem: ^2.0.7 => 2.0.7 
    license-checker: ^25.0.1 => 25.0.1 
    loader-runner:  undefined ()
    loader-utils:  undefined ()
    lodash: ^4.17.21 => 4.17.21 
    lodash.curry:  undefined ()
    lru-cache:  undefined ()
    lucide-react: ^0.428.0 => 0.428.0 (0.453.0)
    luxon: ^3.4.3 => 3.4.3 
    match-sorter: 6.3.0 => 6.3.0 
    mathjs: ^10.6.1 => 10.6.4 
    mini-css-extract-plugin:  undefined ()
    nanoid: ^5.1.0 => undefined (5.1.0, , 3.3.8)
    native-url:  undefined ()
    neo-async:  undefined ()
    next: 14.2.3 => 14.2.3 
    next-extra: ^0.5.0 => 0.5.0 
    next-themes: ^0.3.0 => 0.3.0 
    node-fetch:  undefined ()
    node-html-parser:  undefined ()
    nodemon: ^2.0.7 => 2.0.22 
    nx: 20.1.2 => 20.1.2 (20.0.0)
    nyc: ^17.1.0 => 17.1.0 (15.1.0)
    object-hash: ^3.0.0 => 3.0.0 
    ora:  undefined ()
    os-browserify:  undefined ()
    p-limit:  undefined ()
    path-browserify:  undefined ()
    picomatch:  undefined ()
    ping: ^0.4.0 => 0.4.4 
    pino: ^8.14.1 => 8.14.1 
    pino-http: ^8.3.3 => 8.3.3 
    pino-pretty: ^10.3.1 => 10.3.1 
    platform:  undefined ()
    postcss: 8.4.38 => 8.4.38 (8.4.31, 8.4.49)
    postcss-flexbugs-fixes:  undefined ()
    postcss-modules-extract-imports:  undefined ()
    postcss-modules-local-by-default:  undefined ()
    postcss-modules-scope:  undefined ()
    postcss-modules-values:  undefined ()
    postcss-preset-env:  undefined ()
    postcss-safe-parser:  undefined ()
    postcss-scss:  undefined ()
    postcss-value-parser:  undefined ()
    prettier: ^2.6.2 => 2.8.8 (2.3.2, 1.19.1)
    private:  0.0.0 
    process:  undefined ()
    public-domain-module:  0.0.0 
    punycode:  undefined ()
    querystring-es3:  undefined ()
    raw-body:  undefined ()
    react: 18.3.1 => 18.3.1 
    react-aria: ^3.25.0 => 3.26.0 
    react-builtin:  undefined ()
    react-colorful: ^5.6.1 => 5.6.1 
    react-day-picker: ^9.2.1 => 9.2.1 
    react-dom: 18.3.1 => 18.3.1 
    react-dom-builtin:  undefined ()
    react-dom-experimental-builtin:  undefined ()
    react-error-boundary: ^3.1.4 => 3.1.4 
    react-experimental-builtin:  undefined ()
    react-hook-form: ^7.53.2 => 7.53.2 
    react-hotkeys-hook: ^3.4.7 => 3.4.7 
    react-idle-timer: ^5.4.1 => 5.7.2 
    react-is:  18.2.0 
    react-refresh:  0.12.0 
    react-resizable-panels: ^2.1.7 => 2.1.7 
    react-router-dom: ^6.11.2 => 6.11.2 
    react-server-dom-turbopack-builtin:  undefined ()
    react-server-dom-turbopack-experimental-builtin:  undefined ()
    react-server-dom-webpack-builtin:  undefined ()
    react-server-dom-webpack-experimental-builtin:  undefined ()
    react-stately: ^3.22.0 => 3.24.0 
    react-syntax-highlighter: ^15.5.0 => 15.5.0 
    recharts: ^2.13.2 => 2.13.2 
    regenerator-runtime: 0.13.7 => 0.13.7 (0.14.1, 0.11.1, 0.13.4)
    sass-loader:  undefined ()
    scheduler-builtin:  undefined ()
    scheduler-experimental-builtin:  undefined ()
    schema-utils:  undefined ()
    semver:  undefined ()
    send:  undefined ()
    server-only:  0.0.1 
    setimmediate:  undefined ()
    shell-quote:  undefined ()
    slack-block-builder: ^2.8.0 => 2.8.0 
    socket.io: ^4.3.2 => 4.7.1 
    socket.io-client: ^4.3.2 => 4.7.1 (4.4.0)
    socket.io-msgpack-parser: ^3.0.2 => 3.0.2 
    source-map:  undefined ()
    source-map08:  undefined ()
    stacktrace-parser:  undefined ()
    statsig-node: ^6.3.1 => 6.3.1 
    storybook: ^8.4.7 => 8.4.7 
    stream-browserify:  undefined ()
    stream-http:  undefined ()
    string-hash:  undefined ()
    string_decoder:  undefined ()
    strip-ansi:  undefined ()
    style-loader: ^3.3.0 => 3.3.3 
    stylus: 0.59.0 => 0.59.0 (0.64.0)
    stylus-loader: ^7.1.0 => 7.1.3 
    superstruct:  undefined ()
    supertest: ^6.3.1 => 6.3.3 
    swagger-jsdoc: ^6.1.0 => 6.2.8 
    swagger-ui-express: ^4.3.0 => 4.6.3 
    tailwind-merge: ^2.5.4 => 2.5.4 
    tailwindcss: ^3.4.6 => 3.4.15 
    tailwindcss-animate: ^1.0.7 => 1.0.7 
    tar:  undefined ()
    temp: ^0.9.4 => 0.9.4 
    terser:  undefined ()
    text-table:  undefined ()
    three: ^0.152.2 => 0.152.2 
    timers-browserify:  undefined ()
    tippy-react-headless:  0.1.0 
    transport:  0.0.1 
    ts-jest: ^29.1.0 => 29.1.2 
    ts-json-schema-generator: ^1.0.0 => 1.2.0 
    ts-node: 10.9.1 => 10.9.1 
    tslib: ^2.3.0 => 2.6.2 (2.0.3, 2.4.1, 2.8.1, 1.14.1, 2.2.0, 2.3.1, 2.7.0, 2.8.0)
    tty-browserify:  undefined ()
    typescript: 5.5.4 => 5.5.4 (4.4.4, 4.9.5, 5.0.4, 5.4.5)
    ua-parser-js:  undefined ()
    unistore:  undefined ()
    unzipper: ^0.12.3 => 0.12.3 
    url-loader: ^4.1.1 => 4.1.1 
    util:  undefined ()
    uuid: ^10.0.0 => 10.0.0 (9.0.1, 8.3.2, 3.4.0)
    vite: 5.2.10 => 5.2.10 
    vite-plugin-checker: ^0.6.1 => 0.6.1 
    vite-plugin-comlink: ^3.0.5 => 3.0.5 
    vite-plugin-dts: 2.3.0 => 2.3.0 
    vite-plugin-eslint: ^1.8.1 => 1.8.1 
    vite-plugin-istanbul: ^6.0.2 => 6.0.2 
    vite-tsconfig-paths: 4.2.0 => 4.2.0 
    vitest: ^1.5.3 => 1.5.3 (3.0.8)
    vm-browserify:  undefined ()
    watchpack:  undefined ()
    web-vitals: ^2.1.2 => 2.1.4 ()
    webpack:  undefined ()
    webpack-sources:  undefined ()
    ws:  undefined ()
    yaml: 2.0.0-8 => 2.0.0-8 (1.10.2, 2.7.0, 2.6.0, 2.4.1, 2.0.0-1)
    zod: ^3.22.4 => 3.24.2 (3.23.8, )
    zustand: ^4.3.7 => 4.5.6 (3.7.2)
  npmGlobalPackages:
    corepack: 0.31.0
    npm: 10.9.2


Describe the bug

I have nested custom types I am trying to use in a model. When I then generate code with ampx generate graphql-client-code the types are missing the nested custom types in some instances.

const MyModel = a
  .model({ id: a.id(), foo: a.ref('Foo') })
  .authorization(a => [a.authenticated()]);
const Foo = a.customType({ bar: a.ref('Bar'), qux: a.integer() });
const Bar = a.customType({ baz: a.integer() });

const schema = a
  .schema({
    MyModel,
    Foo,
    Bar,

generates

export type CreateMyModelInput = {
  foo?: FooInput | null,
  id?: string | null,
};

export type FooInput = {
  bar?: BarInput | null,
  qux?: number | null,
};

export type BarInput = {
  baz?: number | null,
};

export type CreateMyModelMutationVariables = {
  condition?: ModelMyModelConditionInput | null,
  input: CreateMyModelInput,
};

export type CreateMyModelMutation = {
  createMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export const createMyModel = /* GraphQL */ `mutation CreateMyModel(
  $condition: ModelMyModelConditionInput
  $input: CreateMyModelInput!
) {
  createMyModel(condition: $condition, input: $input) {
    createdAt
    foo {
      qux
      __typename
    }
    id
    updatedAt
    __typename
  }
}
` as GeneratedMutation<
  APITypes.CreateMyModelMutationVariables,
  APITypes.CreateMyModelMutation
>;

you can see CreateMyModelInput has the full set of types but CreateMyModelMutation and createMyModel do not. This occurs whether foo.bar is assigned a.ref('Bar') or directly integrates another custom type const Foo = a.customType({ bar: a.customType({ baz: a.integer() }), qux: a.integer() });

Expected behavior

The nested types are included in the generated code.

Reproduction steps

  • Create a schema matching what is described above.
  • npx ampx generate graphql-client-code
  • Look at the generated code

Code Snippet

// Put your code below this line.

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

@github-actions github-actions bot added pending-triage Issues that need further discussion to determine pending-maintainer-response Issue is pending a response from the Amplify team. labels Mar 14, 2025
@yuhengshs yuhengshs transferred this issue from aws-amplify/amplify-js Mar 14, 2025
@yuhengshs
Copy link

Hi @csmith-rtr ,

Thanks for reporting this, I will transfer this issue to amplify-data team for further assistance.

@stocaaro
Copy link
Member

stocaaro commented Mar 14, 2025

I'm trying to reproduce the described experience. When I setup the schema described above:

const schema = a.schema({
  Foo: a.customType({ bar: a.ref('Bar'), qux: a.integer() }),
  Bar: a.customType({ baz: a.integer() }),
  MyModel: a
  .model({ id: a.id(), foo: a.ref('Foo') })
  .authorization(a => [a.authenticated()]),
}).authorization((allow) => [allow.publicApiKey()]);

and then generate the client code npx ampx generate graphql-client-code

I get API.ts generated file includes types for both Foo and Bar. Open to see full file.
/* tslint:disable */
/* eslint-disable */
//  This file was automatically generated and should not be edited.

export type MyModel = {
  __typename: "MyModel",
  createdAt: string,
  foo?: Foo | null,
  id: string,
  updatedAt: string,
};

export type Foo = {
  __typename: "Foo",
  bar?: Bar | null,
  qux?: number | null,
};

export type Bar = {
  __typename: "Bar",
  baz?: number | null,
};

export type ModelMyModelFilterInput = {
  and?: Array< ModelMyModelFilterInput | null > | null,
  createdAt?: ModelStringInput | null,
  id?: ModelIDInput | null,
  not?: ModelMyModelFilterInput | null,
  or?: Array< ModelMyModelFilterInput | null > | null,
  updatedAt?: ModelStringInput | null,
};

export type ModelStringInput = {
  attributeExists?: boolean | null,
  attributeType?: ModelAttributeTypes | null,
  beginsWith?: string | null,
  between?: Array< string | null > | null,
  contains?: string | null,
  eq?: string | null,
  ge?: string | null,
  gt?: string | null,
  le?: string | null,
  lt?: string | null,
  ne?: string | null,
  notContains?: string | null,
  size?: ModelSizeInput | null,
};

export enum ModelAttributeTypes {
  _null = "_null",
  binary = "binary",
  binarySet = "binarySet",
  bool = "bool",
  list = "list",
  map = "map",
  number = "number",
  numberSet = "numberSet",
  string = "string",
  stringSet = "stringSet",
}


export type ModelSizeInput = {
  between?: Array< number | null > | null,
  eq?: number | null,
  ge?: number | null,
  gt?: number | null,
  le?: number | null,
  lt?: number | null,
  ne?: number | null,
};

export type ModelIDInput = {
  attributeExists?: boolean | null,
  attributeType?: ModelAttributeTypes | null,
  beginsWith?: string | null,
  between?: Array< string | null > | null,
  contains?: string | null,
  eq?: string | null,
  ge?: string | null,
  gt?: string | null,
  le?: string | null,
  lt?: string | null,
  ne?: string | null,
  notContains?: string | null,
  size?: ModelSizeInput | null,
};

export enum ModelSortDirection {
  ASC = "ASC",
  DESC = "DESC",
}


export type ModelMyModelConnection = {
  __typename: "ModelMyModelConnection",
  items:  Array<MyModel | null >,
  nextToken?: string | null,
};

export type ModelMyModelConditionInput = {
  and?: Array< ModelMyModelConditionInput | null > | null,
  createdAt?: ModelStringInput | null,
  not?: ModelMyModelConditionInput | null,
  or?: Array< ModelMyModelConditionInput | null > | null,
  updatedAt?: ModelStringInput | null,
};

export type CreateMyModelInput = {
  foo?: FooInput | null,
  id?: string | null,
};

export type FooInput = {
  bar?: BarInput | null,
  qux?: number | null,
};

export type BarInput = {
  baz?: number | null,
};

export type DeleteMyModelInput = {
  id: string,
};

export type UpdateMyModelInput = {
  foo?: FooInput | null,
  id: string,
};

export type ModelSubscriptionMyModelFilterInput = {
  and?: Array< ModelSubscriptionMyModelFilterInput | null > | null,
  createdAt?: ModelSubscriptionStringInput | null,
  id?: ModelSubscriptionIDInput | null,
  or?: Array< ModelSubscriptionMyModelFilterInput | null > | null,
  updatedAt?: ModelSubscriptionStringInput | null,
};

export type ModelSubscriptionStringInput = {
  beginsWith?: string | null,
  between?: Array< string | null > | null,
  contains?: string | null,
  eq?: string | null,
  ge?: string | null,
  gt?: string | null,
  in?: Array< string | null > | null,
  le?: string | null,
  lt?: string | null,
  ne?: string | null,
  notContains?: string | null,
  notIn?: Array< string | null > | null,
};

export type ModelSubscriptionIDInput = {
  beginsWith?: string | null,
  between?: Array< string | null > | null,
  contains?: string | null,
  eq?: string | null,
  ge?: string | null,
  gt?: string | null,
  in?: Array< string | null > | null,
  le?: string | null,
  lt?: string | null,
  ne?: string | null,
  notContains?: string | null,
  notIn?: Array< string | null > | null,
};

export type GetMyModelQueryVariables = {
  id: string,
};

export type GetMyModelQuery = {
  getMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type ListMyModelsQueryVariables = {
  filter?: ModelMyModelFilterInput | null,
  id?: string | null,
  limit?: number | null,
  nextToken?: string | null,
  sortDirection?: ModelSortDirection | null,
};

export type ListMyModelsQuery = {
  listMyModels?:  {
    __typename: "ModelMyModelConnection",
    items:  Array< {
      __typename: "MyModel",
      createdAt: string,
      id: string,
      updatedAt: string,
    } | null >,
    nextToken?: string | null,
  } | null,
};

export type CreateMyModelMutationVariables = {
  condition?: ModelMyModelConditionInput | null,
  input: CreateMyModelInput,
};

export type CreateMyModelMutation = {
  createMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type DeleteMyModelMutationVariables = {
  condition?: ModelMyModelConditionInput | null,
  input: DeleteMyModelInput,
};

export type DeleteMyModelMutation = {
  deleteMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type UpdateMyModelMutationVariables = {
  condition?: ModelMyModelConditionInput | null,
  input: UpdateMyModelInput,
};

export type UpdateMyModelMutation = {
  updateMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type OnCreateMyModelSubscriptionVariables = {
  filter?: ModelSubscriptionMyModelFilterInput | null,
};

export type OnCreateMyModelSubscription = {
  onCreateMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type OnDeleteMyModelSubscriptionVariables = {
  filter?: ModelSubscriptionMyModelFilterInput | null,
};

export type OnDeleteMyModelSubscription = {
  onDeleteMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type OnUpdateMyModelSubscriptionVariables = {
  filter?: ModelSubscriptionMyModelFilterInput | null,
};

export type OnUpdateMyModelSubscription = {
  onUpdateMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

Did you build the related backend for your latest schema before generating the graphql files?

Thanks,
Aaron

@csmith-rtr
Copy link
Author

csmith-rtr commented Mar 14, 2025

It looks like you are still only seeing the types in a subset of the generated code - for example

export type GetMyModelQuery = {
  getMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

export type OnCreateMyModelSubscription = {
  onCreateMyModel?:  {
    __typename: "MyModel",
    createdAt: string,
    foo?:  {
      __typename: "Foo",
      qux?: number | null,
    } | null,
    id: string,
    updatedAt: string,
  } | null,
};

the above foo types do not include bar though type FooInput does

@stocaaro stocaaro transferred this issue from aws-amplify/amplify-data Mar 14, 2025
@stocaaro
Copy link
Member

Very interesting. I'm pretty sure these files are generated by the codegen. I'm transferring this to that repository for further review.

@csmith-rtr
Copy link
Author

Not sure its related but I originally found this because the subscriptions for nested custom types weren't working - after calling the update mutation the values were always null though dynamo would update correctly.

For now I've reverted to using a.json() and everything is working, just without the auto-type safety.

@dpilch dpilch added bug Something isn't working and removed pending-triage Issues that need further discussion to determine labels Mar 21, 2025
@AnilMaktala AnilMaktala added to-be-reproduced Gen 2 and removed pending-maintainer-response Issue is pending a response from the Amplify team. to-be-reproduced labels Mar 25, 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
Projects
None yet
Development

No branches or pull requests

5 participants