amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

Support cyclical models in datastore

Open johnpc opened this issue 3 years ago • 2 comments

Is this related to a new or existing framework?

No response

Is this related to a new or existing API?

DataStore

Is this related to another service?

No response

Describe the feature you'd like to request

Currently, DataStore does not support models with circular references. For example this schema:

type SomeType {
  NewField: String
}

type TestModel @model @auth(rules: [{allow: public}]) {
  id: ID!
  untitledfield: [SomeType]
}

type MenuModel @model @auth(rules: [{allow: public}]) {
  id: ID!
  menu: Menu
}

type Menu {
  name: ID!
  submenus: [Menu]
}

calling initialize method will trigger the following error:

RangeError: Maximum call stack size exceeded
    at Object.toString (<anonymous>)
    at isGraphQLScalarType (types.ts:284:1)
    at utils.ts:126:1

https://github.com/aws-amplify/amplify-adminui/issues/423

Describe the solution you'd like

I'd like DataStore to be able to handle circular dependencies

Describe alternatives you've considered

I've considered flattening my schema to remove recursive models, and using AppSync api calls directly instead of datastore

Additional context

https://github.com/aws-amplify/amplify-adminui/issues/423

Is this something that you'd be interested in working on?

  • [ ] 👋 I may be able to implement this feature request
  • [ ] ⚠️ This feature might incur a breaking change

johnpc avatar Jul 05 '22 14:07 johnpc

Duplicate of https://github.com/aws-amplify/amplify-js/issues/6736

dpilch avatar Jul 07 '22 17:07 dpilch

What's the update on this?

joeykay9 avatar May 15 '24 22:05 joeykay9