Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove global Ember import #413

Merged

Conversation

balinterdi
Copy link
Contributor

This is one of the deprecations that prevent Ember 4 compatibility.

isTesting can be imported from @embroider/macros and relying on this package does not mean the add-on needs to be built with Embroider.

@josemarluedke josemarluedke merged commit 22e4a48 into ember-graphql:master Mar 14, 2022
@balinterdi
Copy link
Contributor Author

@josemarluedke I wouldn't have merged this as it still fails on ember-canary (and maybe on other Ember versions, too, but they were cancelled early) 😬

@josemarluedke
Copy link
Member

I believe it's failing because ember-auto-import v1 is used and ember v4 requires v2.

@balinterdi
Copy link
Contributor Author

If that was the case then #414 would pass, wouldn't it? 🤔

@josemarluedke
Copy link
Member

Yes, when rebased with the changes from this PR.

@josemarluedke
Copy link
Member

Published as v4.0.0.

@@ -137,7 +137,7 @@ export default class ApolloService extends Service {
let config = getOwner(this).resolveRegistration('config:environment');
if (config && config.apollo) {
return config.apollo;
} else if (Ember.testing) {
} else if (isTesting()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could (should?) be combined with macroCondition(...), so the testing code is stripped out when isTesting() is false.

@@ -137,7 +137,7 @@ export default class ApolloService extends Service {
let config = getOwner(this).resolveRegistration('config:environment');
if (config && config.apollo) {
return config.apollo;
} else if (Ember.testing) {
} else if (isTesting()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could (should?) be combined with macroCondition(...), so the testing code is stripped out when isTesting() is false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bertdeblock Thanks for pointing this out! I created another PR to address this: #416 /cc @josemarluedke

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@balinterdi Sweet! 👍

@bertdeblock
Copy link
Contributor

bertdeblock commented Mar 15, 2022

I think the PR description is a bit confusing.
import Ember from 'ember'; was never deprecated, and the removed code works just fine in v4.
We have been using ember-apollo-client in v4 for a while now.
That being said, using macroCondition(isTesting()) is probably better anyways to strip out testing code.

@balinterdi
Copy link
Contributor Author

@bertdeblock You're right. I was under the impression that importing the global Ember will throw an error in Ember 4 but now I re-read the entry in the deprecation guide and it turns out that it only throws if you use Ember without importing it.

I still think this is very valuable to have (otherwise this add-on prevents tree-shaking parts of Ember) but the description is indeed misleading, @josemarluedke sorry about that.

@bertdeblock
Copy link
Contributor

bertdeblock commented Mar 15, 2022

I still think this is very valuable to have

Yup, this seems better anyways 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants