diff --git a/packages/-ember-data/tests/integration/adapter/json-api-adapter-test.js b/packages/-ember-data/tests/integration/adapter/json-api-adapter-test.js index ee394e8ecd2..ce1ae66a818 100644 --- a/packages/-ember-data/tests/integration/adapter/json-api-adapter-test.js +++ b/packages/-ember-data/tests/integration/adapter/json-api-adapter-test.js @@ -240,6 +240,48 @@ module('integration/adapter/json-api-adapter - JSONAPIAdapter', function(hooks) assert.equal(posts.get('firstObject.title'), 'Ember.js rocks', 'Sets correct title to record'); }); + test('find many polymorphic records', async function(assert) { + assert.expect(4); + + ajaxResponse([ + { + data: [ + { + type: 'github-handles', + id: '1', + attributes: { + username: 'ykatz', + }, + }, + { + type: 'twitter-handles', + id: '2', + attributes: { + nickname: 'ykatz', + }, + }, + ], + included: [], + }, + ]); + + let handles = await store.findAll('handle'); + + let twitter_handles = store.peekAll('twitter-handles'); + let github_handles = store.peekAll('github-handles'); + + //This should work b/c we loaded these types from the API, but it doesn't + assert.equal(twitter_handles.get('length'), 1); + assert.equal(github_handles.get('length'), 1); + + assert.equal(passedUrl[0], '/handles', 'Builds correct URL'); + + //These won't work because we didn't load anything of the base type 'handles' + assert.equal(handles.get('length'), 2, 'Returns the correct number of records'); + assert.equal(handles.get('firstObject.username'), 'ykatz', 'Sets correct username to record'); + assert.equal(handles.get('secondObject.nickname'), 'ykatz', 'Sets correct username to record'); + }); + test('queryRecord - primary data being a single record', async function(assert) { ajaxResponse([ { diff --git a/packages/store/addon/-private/identifiers/cache.ts b/packages/store/addon/-private/identifiers/cache.ts index 1dd4d6f3127..83eef6218f0 100644 --- a/packages/store/addon/-private/identifiers/cache.ts +++ b/packages/store/addon/-private/identifiers/cache.ts @@ -496,7 +496,6 @@ function performRecordIdentifierUpdate( updateFn: UpdateMethod ) { let { id, lid } = data; - let type = data.type && normalizeModelName(data.type); if (DEBUG) { // get the mutable instance behind our proxy wrapper @@ -526,13 +525,6 @@ function performRecordIdentifierUpdate( } } - // TODO consider just ignoring here to allow flexible polymorphic support - if (type && type !== identifier.type) { - throw new Error( - `The 'type' for a RecordIdentifier cannot be updated once it has been set. Attempted to set type for '${wrapper}' to '${type}'.` - ); - } - updateFn(wrapper, data, 'record'); } else { updateFn(identifier, data, 'record');