aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.41k stars 2.12k forks source link

Datastore delete function throws a "TypeError: Cannot read property 'split' of undefined" #10814

Closed shoopapa closed 1 year ago

shoopapa commented 1 year ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

GraphQL API, DataStore

Amplify Categories

auth, api

Environment information

``` System: OS: macOS 12.1 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 90.09 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.6.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.15.0 - /usr/local/bin/npm Browsers: Chrome: 108.0.5359.124 Safari: 15.2 npmPackages: @aws-amplify/ui-react: ^4.0.3 => 4.0.3 @aws-amplify/ui-react-internal: undefined () @azure/core-asynciterator-polyfill: ^1.0.2 => 1.0.2 @babel/core: ^7.12.9 => 7.20.2 @babel/runtime: ^7.12.5 => 7.20.1 @react-native-async-storage/async-storage: ^1.17.11 => 1.17.11 @react-native-community/eslint-config: ^2.0.0 => 2.0.0 @react-native-community/netinfo: ^9.3.6 => 9.3.6 @react-native-picker/picker: ^2.4.2 => 2.4.8 @react-navigation/bottom-tabs: ^6.3.2 => 6.4.1 @react-navigation/native: ^6.0.11 => 6.0.14 (3.8.4) @react-navigation/native-stack: ^6.7.0 => 6.9.2 @react-navigation/stack: ^6.2.2 => 6.3.5 @types/jest: ^26.0.23 => 26.0.24 @types/lodash.debounce: ^4.0.7 => 4.0.7 @types/react-native: ^0.67.3 => 0.67.16 @types/react-native-svg-charts: ^5.0.12 => 5.0.12 @types/react-native-vector-icons: ^6.4.11 => 6.4.12 @types/react-test-renderer: ^17.0.1 => 17.0.2 @typescript-eslint/eslint-plugin: ^5.17.0 => 5.44.0 (3.10.1) @typescript-eslint/parser: ^5.17.0 => 5.44.0 (3.10.1) HelloWorld: 0.0.1 amazon-cognito-identity-js: ^5.2.10 => 5.2.12 (6.1.0) aws-amplify: ^5.0.6 => 5.0.6 aws-amplify-react-native: ^7.0.1 => 7.0.1 babel-jest: ^26.6.3 => 26.6.3 eslint: ^7.32.0 => 7.32.0 hermes-inspector-msggen: 1.0.0 javascript-time-ago: ^2.5.7 => 2.5.9 javascript-time-ago/cache: undefined () javascript-time-ago/commonjs: undefined () javascript-time-ago/gradation: undefined () javascript-time-ago/load-all-locales: undefined () javascript-time-ago/locale/af: undefined () javascript-time-ago/locale/am: undefined () javascript-time-ago/locale/ar: undefined () javascript-time-ago/locale/ar-AE: undefined () javascript-time-ago/locale/as: undefined () javascript-time-ago/locale/ast: undefined () javascript-time-ago/locale/az: undefined () javascript-time-ago/locale/be: undefined () javascript-time-ago/locale/bg: undefined () javascript-time-ago/locale/bgc: undefined () javascript-time-ago/locale/bn: undefined () javascript-time-ago/locale/br: undefined () javascript-time-ago/locale/brx: undefined () javascript-time-ago/locale/bs: undefined () javascript-time-ago/locale/bs-Cyrl: undefined () javascript-time-ago/locale/ca: undefined () javascript-time-ago/locale/ccp: undefined () javascript-time-ago/locale/ce: undefined () javascript-time-ago/locale/ceb: undefined () javascript-time-ago/locale/chr: undefined () javascript-time-ago/locale/cs: undefined () javascript-time-ago/locale/cv: undefined () javascript-time-ago/locale/cy: undefined () javascript-time-ago/locale/da: undefined () javascript-time-ago/locale/de: undefined () javascript-time-ago/locale/dsb: undefined () javascript-time-ago/locale/dz: undefined () javascript-time-ago/locale/ee: undefined () javascript-time-ago/locale/el: undefined () javascript-time-ago/locale/en: undefined () javascript-time-ago/locale/en-001: undefined () javascript-time-ago/locale/en-150: undefined () javascript-time-ago/locale/en-AG: undefined () javascript-time-ago/locale/en-AI: undefined () javascript-time-ago/locale/en-AT: undefined () javascript-time-ago/locale/en-AU: undefined () javascript-time-ago/locale/en-BB: undefined () javascript-time-ago/locale/en-BE: undefined () javascript-time-ago/locale/en-BM: undefined () javascript-time-ago/locale/en-BS: undefined () javascript-time-ago/locale/en-BW: undefined () javascript-time-ago/locale/en-BZ: undefined () javascript-time-ago/locale/en-CA: undefined () javascript-time-ago/locale/en-CC: undefined () javascript-time-ago/locale/en-CH: undefined () javascript-time-ago/locale/en-CK: undefined () javascript-time-ago/locale/en-CM: undefined () javascript-time-ago/locale/en-CX: undefined () javascript-time-ago/locale/en-CY: undefined () javascript-time-ago/locale/en-DE: undefined () javascript-time-ago/locale/en-DG: undefined () javascript-time-ago/locale/en-DK: undefined () javascript-time-ago/locale/en-DM: undefined () javascript-time-ago/locale/en-ER: undefined () javascript-time-ago/locale/en-FI: undefined () javascript-time-ago/locale/en-FJ: undefined () javascript-time-ago/locale/en-FK: undefined () javascript-time-ago/locale/en-FM: undefined () javascript-time-ago/locale/en-GB: undefined () javascript-time-ago/locale/en-GD: undefined () javascript-time-ago/locale/en-GG: undefined () javascript-time-ago/locale/en-GH: undefined () javascript-time-ago/locale/en-GI: undefined () javascript-time-ago/locale/en-GM: undefined () javascript-time-ago/locale/en-GY: undefined () javascript-time-ago/locale/en-HK: undefined () javascript-time-ago/locale/en-IE: undefined () javascript-time-ago/locale/en-IL: undefined () javascript-time-ago/locale/en-IM: undefined () javascript-time-ago/locale/en-IN: undefined () javascript-time-ago/locale/en-IO: undefined () javascript-time-ago/locale/en-JE: undefined () javascript-time-ago/locale/en-JM: undefined () javascript-time-ago/locale/en-KE: undefined () javascript-time-ago/locale/en-KI: undefined () javascript-time-ago/locale/en-KN: undefined () javascript-time-ago/locale/en-KY: undefined () javascript-time-ago/locale/en-LC: undefined () javascript-time-ago/locale/en-LR: undefined () javascript-time-ago/locale/en-LS: undefined () javascript-time-ago/locale/en-MG: undefined () javascript-time-ago/locale/en-MO: undefined () javascript-time-ago/locale/en-MS: undefined () javascript-time-ago/locale/en-MT: undefined () javascript-time-ago/locale/en-MU: undefined () javascript-time-ago/locale/en-MV: undefined () javascript-time-ago/locale/en-MW: undefined () javascript-time-ago/locale/en-MY: undefined () javascript-time-ago/locale/en-NA: undefined () javascript-time-ago/locale/en-NF: undefined () javascript-time-ago/locale/en-NG: undefined () javascript-time-ago/locale/en-NL: undefined () javascript-time-ago/locale/en-NR: undefined () javascript-time-ago/locale/en-NU: undefined () javascript-time-ago/locale/en-NZ: undefined () javascript-time-ago/locale/en-PG: undefined () javascript-time-ago/locale/en-PK: undefined () javascript-time-ago/locale/en-PN: undefined () javascript-time-ago/locale/en-PW: undefined () javascript-time-ago/locale/en-RW: undefined () javascript-time-ago/locale/en-SB: undefined () javascript-time-ago/locale/en-SC: undefined () javascript-time-ago/locale/en-SD: undefined () javascript-time-ago/locale/en-SE: undefined () javascript-time-ago/locale/en-SG: undefined () javascript-time-ago/locale/en-SH: undefined () javascript-time-ago/locale/en-SI: undefined () javascript-time-ago/locale/en-SL: undefined () javascript-time-ago/locale/en-SS: undefined () javascript-time-ago/locale/en-SX: undefined () javascript-time-ago/locale/en-SZ: undefined () javascript-time-ago/locale/en-TC: undefined () javascript-time-ago/locale/en-TK: undefined () javascript-time-ago/locale/en-TO: undefined () javascript-time-ago/locale/en-TT: undefined () javascript-time-ago/locale/en-TV: undefined () javascript-time-ago/locale/en-TZ: undefined () javascript-time-ago/locale/en-UG: undefined () javascript-time-ago/locale/en-VC: undefined () javascript-time-ago/locale/en-VG: undefined () javascript-time-ago/locale/en-VU: undefined () javascript-time-ago/locale/en-WS: undefined () javascript-time-ago/locale/en-ZA: undefined () javascript-time-ago/locale/en-ZM: undefined () javascript-time-ago/locale/en-ZW: undefined () javascript-time-ago/locale/eo: undefined () javascript-time-ago/locale/es: undefined () javascript-time-ago/locale/es-419: undefined () javascript-time-ago/locale/es-AR: undefined () javascript-time-ago/locale/es-BO: undefined () javascript-time-ago/locale/es-BR: undefined () javascript-time-ago/locale/es-BZ: undefined () javascript-time-ago/locale/es-CL: undefined () javascript-time-ago/locale/es-CO: undefined () javascript-time-ago/locale/es-CR: undefined () javascript-time-ago/locale/es-CU: undefined () javascript-time-ago/locale/es-DO: undefined () javascript-time-ago/locale/es-EC: undefined () javascript-time-ago/locale/es-GT: undefined () javascript-time-ago/locale/es-HN: undefined () javascript-time-ago/locale/es-MX: undefined () javascript-time-ago/locale/es-NI: undefined () javascript-time-ago/locale/es-PA: undefined () javascript-time-ago/locale/es-PE: undefined () javascript-time-ago/locale/es-PR: undefined () javascript-time-ago/locale/es-PY: undefined () javascript-time-ago/locale/es-SV: undefined () javascript-time-ago/locale/es-US: undefined () javascript-time-ago/locale/es-UY: undefined () javascript-time-ago/locale/es-VE: undefined () javascript-time-ago/locale/et: undefined () javascript-time-ago/locale/eu: undefined () javascript-time-ago/locale/fa: undefined () javascript-time-ago/locale/ff-Adlm: undefined () javascript-time-ago/locale/fi: undefined () javascript-time-ago/locale/fil: undefined () javascript-time-ago/locale/fo: undefined () javascript-time-ago/locale/fr: undefined () javascript-time-ago/locale/fr-CA: undefined () javascript-time-ago/locale/fur: undefined () javascript-time-ago/locale/fy: undefined () javascript-time-ago/locale/ga: undefined () javascript-time-ago/locale/gd: undefined () javascript-time-ago/locale/gl: undefined () javascript-time-ago/locale/gu: undefined () javascript-time-ago/locale/ha: undefined () javascript-time-ago/locale/he: undefined () javascript-time-ago/locale/hi: undefined () javascript-time-ago/locale/hi-Latn: undefined () javascript-time-ago/locale/hr: undefined () javascript-time-ago/locale/hsb: undefined () javascript-time-ago/locale/hu: undefined () javascript-time-ago/locale/hy: undefined () javascript-time-ago/locale/ia: undefined () javascript-time-ago/locale/id: undefined () javascript-time-ago/locale/ig: undefined () javascript-time-ago/locale/is: undefined () javascript-time-ago/locale/it: undefined () javascript-time-ago/locale/ja: undefined () javascript-time-ago/locale/jgo: undefined () javascript-time-ago/locale/jv: undefined () javascript-time-ago/locale/ka: undefined () javascript-time-ago/locale/kea: undefined () javascript-time-ago/locale/kgp: undefined () javascript-time-ago/locale/kk: undefined () javascript-time-ago/locale/kl: undefined () javascript-time-ago/locale/km: undefined () javascript-time-ago/locale/kn: undefined () javascript-time-ago/locale/ko: undefined () javascript-time-ago/locale/kok: undefined () javascript-time-ago/locale/ks: undefined () javascript-time-ago/locale/ksh: undefined () javascript-time-ago/locale/ku: undefined () javascript-time-ago/locale/ky: undefined () javascript-time-ago/locale/lb: undefined () javascript-time-ago/locale/lkt: undefined () javascript-time-ago/locale/lo: undefined () javascript-time-ago/locale/lt: undefined () javascript-time-ago/locale/lv: undefined () javascript-time-ago/locale/mai: undefined () javascript-time-ago/locale/mi: undefined () javascript-time-ago/locale/mk: undefined () javascript-time-ago/locale/ml: undefined () javascript-time-ago/locale/mn: undefined () javascript-time-ago/locale/mni: undefined () javascript-time-ago/locale/mr: undefined () javascript-time-ago/locale/ms: undefined () javascript-time-ago/locale/mt: undefined () javascript-time-ago/locale/my: undefined () javascript-time-ago/locale/mzn: undefined () javascript-time-ago/locale/nb: undefined () javascript-time-ago/locale/ne: undefined () javascript-time-ago/locale/nl: undefined () javascript-time-ago/locale/nn: undefined () javascript-time-ago/locale/no: undefined () javascript-time-ago/locale/or: undefined () javascript-time-ago/locale/pa: undefined () javascript-time-ago/locale/pcm: undefined () javascript-time-ago/locale/pl: undefined () javascript-time-ago/locale/ps: undefined () javascript-time-ago/locale/ps-PK: undefined () javascript-time-ago/locale/pt: undefined () javascript-time-ago/locale/pt-AO: undefined () javascript-time-ago/locale/pt-CH: undefined () javascript-time-ago/locale/pt-CV: undefined () javascript-time-ago/locale/pt-GQ: undefined () javascript-time-ago/locale/pt-GW: undefined () javascript-time-ago/locale/pt-LU: undefined () javascript-time-ago/locale/pt-MO: undefined () javascript-time-ago/locale/pt-MZ: undefined () javascript-time-ago/locale/pt-PT: undefined () javascript-time-ago/locale/pt-ST: undefined () javascript-time-ago/locale/pt-TL: undefined () javascript-time-ago/locale/qu: undefined () javascript-time-ago/locale/raj: undefined () javascript-time-ago/locale/rm: undefined () javascript-time-ago/locale/ro: undefined () javascript-time-ago/locale/ru: undefined () javascript-time-ago/locale/sah: undefined () javascript-time-ago/locale/sc: undefined () javascript-time-ago/locale/sd: undefined () javascript-time-ago/locale/se: undefined () javascript-time-ago/locale/se-FI: undefined () javascript-time-ago/locale/si: undefined () javascript-time-ago/locale/sk: undefined () javascript-time-ago/locale/sl: undefined () javascript-time-ago/locale/so: undefined () javascript-time-ago/locale/sq: undefined () javascript-time-ago/locale/sr: undefined () javascript-time-ago/locale/sr-Cyrl-BA: undefined () javascript-time-ago/locale/sr-Latn: undefined () javascript-time-ago/locale/sr-Latn-BA: undefined () javascript-time-ago/locale/su: undefined () javascript-time-ago/locale/sv: undefined () javascript-time-ago/locale/sw: undefined () javascript-time-ago/locale/ta: undefined () javascript-time-ago/locale/te: undefined () javascript-time-ago/locale/tg: undefined () javascript-time-ago/locale/th: undefined () javascript-time-ago/locale/ti: undefined () javascript-time-ago/locale/tk: undefined () javascript-time-ago/locale/to: undefined () javascript-time-ago/locale/tr: undefined () javascript-time-ago/locale/tt: undefined () javascript-time-ago/locale/ug: undefined () javascript-time-ago/locale/uk: undefined () javascript-time-ago/locale/ur: undefined () javascript-time-ago/locale/ur-IN: undefined () javascript-time-ago/locale/uz: undefined () javascript-time-ago/locale/uz-Cyrl: undefined () javascript-time-ago/locale/vi: undefined () javascript-time-ago/locale/wae: undefined () javascript-time-ago/locale/wo: undefined () javascript-time-ago/locale/xh: undefined () javascript-time-ago/locale/yi: undefined () javascript-time-ago/locale/yo: undefined () javascript-time-ago/locale/yo-BJ: undefined () javascript-time-ago/locale/yrl: undefined () javascript-time-ago/locale/yue: undefined () javascript-time-ago/locale/yue-Hans: undefined () javascript-time-ago/locale/zh: undefined () javascript-time-ago/locale/zh-Hans-HK: undefined () javascript-time-ago/locale/zh-Hans-MO: undefined () javascript-time-ago/locale/zh-Hans-SG: undefined () javascript-time-ago/locale/zh-Hant: undefined () javascript-time-ago/locale/zh-Hant-HK: undefined () javascript-time-ago/locale/zh-Hant-MO: undefined () javascript-time-ago/locale/zu: undefined () javascript-time-ago/prop-types: undefined () javascript-time-ago/steps: undefined () jest: ^26.6.3 => 26.6.3 lodash.debounce: ^4.0.8 => 4.0.8 metro-react-native-babel-preset: ^0.67.0 => 0.67.0 (0.72.3) prettier: 2.7.1 => 2.7.1 react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-chart-kit: ^6.12.0 => 6.12.0 react-native-config: ^1.4.6 => 1.4.11 react-native-gesture-handler: ^2.5.0 => 2.8.0 react-native-paper: ^4.12.4 => 4.12.5 react-native-safe-area-context: ^4.3.1 => 4.4.1 react-native-screens: ^3.15.0 => 3.18.2 react-native-svg: ^12.4.3 => 12.4.4 (6.5.3) react-native-vector-icons: ^9.2.0 => 9.2.0 react-navigation: ^4.4.4 => 4.4.4 react-test-renderer: 17.0.2 => 17.0.2 react-time-ago: ^7.2.1 => 7.2.1 react-time-ago/commonjs: undefined () typescript: ^4.4.4 => 4.9.3 use-debounce: ^8.0.3 => 8.0.4 npmGlobalPackages: @aws-amplify/cli: 10.5.1 @google/clasp: 2.4.1 eas-cli: 0.47.0 expo-cli: 5.1.2 npm: 8.15.0 react-devtools: 4.23.0 react-native-cli: 2.0.1 react-native: 0.67.2 ts-node: 10.7.0 yarn: 1.22.19 ```

Describe the bug

This error is thrown when running Datastore.delete(session) on a model with @hasmany relationship, if I remove the relation ship then the delete function works correctly, so it seems to be a proper bug.

I tried

  1. delete the related models first await DataStore.delete(session)
  2. delete using a predicate await DataStore.delete(Session, s=> s.id.eq(id))
TypeError: Cannot read property 'split' of undefined
    at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:259931:36)
    at call (native)
    at step (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:100693:27)
    at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:100641:22)
    at fulfilled (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:100600:32)
    at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26816:26)
    at _callTimer (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26731:17)
    at _callReactNativeMicrotasksPass (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26764:17)
    at callReactNativeMicrotasks (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26928:44)
    at __callReactNativeMicrotasks (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2504:46)
    at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2304:45)
    at __guard (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2484:15)
    at flushedQueue (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2303:21)
    at invokeCallbackAndReturnFlushedQueue (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2297:33)

Expected behavior

I expect to be able to delete this model, but I currently cannot delete this model from the datastore API

Reproduction steps

type Session @model @auth(
  rules: [
    {allow: owner}
  ]
) {
  id: ID!
  name: String
  sections: [SessionSection!] @hasMany(indexName: "bySession", fields: ["id"])
}
type SessionSection @model
 @auth(
  rules: [
    {allow: owner}
  ]
) {
  id: ID!
  sessionID: ID! @index(name: "bySession", sortKeyFields: ["start"])
  start: Float!
  end: Float!
}

using this schema and datastore save a model with relationships like so

    const session = new Session({
      name,
    })

    await DataStore.save(session)

    let sectionModels: SessionSection[] = []
    if (sections !== undefined) {
      sections.forEach(s=>{
        const {start,end} = s
        sectionModels.push(new SessionSection({start, end, sessionID:session.id}))
      })
    }
    await Promise.all(sectionModels.map(s=> DataStore.save(s) ))

then try to delete the session await DataStore.delete(session)

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line TypeError: Cannot read property 'split' of undefined at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:259931:36) at call (native) at step (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:100693:27) at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:100641:22) at fulfilled (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:100600:32) at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:53:16) at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:139:27) at apply (native) at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26816:26) at _callTimer (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26731:17) at _callReactNativeMicrotasksPass (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26764:17) at callReactNativeMicrotasks (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:26928:44) at __callReactNativeMicrotasks (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2504:46) at anonymous (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2304:45) at __guard (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2484:15) at flushedQueue (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2303:21) at invokeCallbackAndReturnFlushedQueue (http://192.168.86.24:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.m2trainingcenter.m2gear:2297:33) ```

aws-exports.js

import awsconfig from './src/aws-exports';
Amplify.configure({
  ...awsconfig,
  Analytics: {
    disabled: true,
  },
  maxRecordsToSync: 20,
  DataStore: {
    authModeStrategyType: AuthModeStrategyType.DEFAULT,
  },
});

Manual configuration

No response

Additional configuration

No response

Mobile Device

iphone 13

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

react-native 0.70.6

Makatun commented 1 year ago

Same issue

dpilch commented 1 year ago

I was able to reproduce the issue. I'll look into a fix.

david-mcafee commented 1 year ago

Hi @shoopapa! This is actually a duplicate of https://github.com/aws-amplify/amplify-js/issues/10864 - a known DataStore bug.

A temporary workaround would be to remove the sort key from the child model, as follows:

type Session @model @auth(
  rules: [
    {allow: owner}
  ]
) {
  id: ID!
  name: String
  sections: [SessionSection!] @hasMany(indexName: "bySession", fields: ["id"])
}
type SessionSection @model
 @auth(
  rules: [
    {allow: owner}
  ]
) {
  id: ID!
  sessionID: ID! @index(name: "bySession")
  start: Float!
  end: Float!
}

Let me know if that is an acceptable workaround for you!

dpilch commented 1 year ago

Closing as duplicate. Please move discussion to https://github.com/aws-amplify/amplify-js/issues/10864.