Skip to content

Polymorphism: Expected type <type> to be a valid ResourceType #10531

Description

@st-h

I have several models that reference an event model.

Consider this payload for instance:

project:

{ id: 1 }

event:

{ 
  id: 3,
   record: { 
    type: project,
    id: 1
  }
}

This specifies that the event belongs to project with id 1, and was working fine with ember data models.

Now in warpdrive I am using these schemas:

Project:

export const ProjectSchema = withDefaults({
  type: 'project',
  fields: [
    { kind: 'hasMany', name: 'events', type: 'event', options: { async: false, inverse: 'record', as: 'abstract-record' } }
  ]
})

Event:

export const EventSchema = withDefaults({
  type: 'event',
  fields: [
    { kind: 'belongsTo', name: 'record', type: 'abstract-record', options: { async: false, inverse: 'events', polymorphic: true } }
  ]
})

So, event.record should link the project.
And project.events should have the array of events

However, I get this error from warpdrive when querying events via store.request(...): Error: Expected type abstract-record to be a valid ResourceType and I have no idea what I might be missing.

Versions: all @warp-drive/* at ^5.8.1, using useLegacyStore from @warp-drive/legacy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions