Open joelalejandro opened 3 years ago
Using direct resource imports to set the type in a relationship can produce a dependency cycle.
type
// book.ts import Author from './author'; class Book extends Resource { static schema = { attributes: { title: String; }, relationships: { authors: { hasMany: true, type: () => Author } } } }
// author.ts import Book from './book'; class Author extends Resource { static schema = { attributes: { firstName: String; lastName: String; }, relationships: { books: { hasMany: true, type: () => Book } } } }
We might want to replace type: () => Resource with a string resolver to prevent this and use resourceFor() to resolve the type internally.
type: () => Resource
string
resourceFor()
We can accept both syntaxes to prevent this from becoming a breaking change.
Using direct resource imports to set the
type
in a relationship can produce a dependency cycle.We might want to replace
type: () => Resource
with astring
resolver to prevent this and useresourceFor()
to resolve the type internally.We can accept both syntaxes to prevent this from becoming a breaking change.