Skip to content

Commit

Permalink
fix: add ember-data version check to check if calling .toArray on e…
Browse files Browse the repository at this point in the history
…mber-data arrays is deprecated (#2525)
  • Loading branch information
StephanH90 authored Oct 27, 2023
1 parent 1cf1593 commit a719961
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/addon/services/-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { assert } from "@ember/debug";
import { once } from "@ember/runloop";
import Service, { inject as service } from "@ember/service";
import { camelize } from "@ember/string";
import { dependencySatisfies } from "@embroider/macros";
import { tracked } from "@glimmer/tracking";
import { task } from "ember-concurrency";
import { pluralize } from "ember-inflector";

const toArrayIsDeprecated = dependencySatisfies("ember-data", "^4.7.0");

/**
* Decorator to define a type resolver in the scheduler service.
*
Expand Down Expand Up @@ -37,7 +40,9 @@ function typeResolver(type) {
? yield this.calumaOptions[methodName]?.(uncachedIdentifiers)
: [];

const allResults = [...cached, ...(result?.toArray?.() ?? result ?? [])];
const allResults = toArrayIsDeprecated
? [...cached, ...(result ?? [])]
: [...cached, ...(result?.toArray?.() ?? result ?? [])];

if (result?.length) {
this[`${type}Cache`] = allResults;
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@apollo/client": "^3.7.17",
"@ember/string": "^3.1.1",
"@embroider/macros": "^1.13.0",
"@glimmer/tracking": "^1.1.2",
"ember-apollo-client": "~4.0.2",
"ember-auto-import": "^2.6.3",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a719961

Please sign in to comment.