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

JSONAPISerializer error when following 4.1 docs #92

Open
cloke opened this issue Feb 17, 2022 · 6 comments
Open

JSONAPISerializer error when following 4.1 docs #92

cloke opened this issue Feb 17, 2022 · 6 comments

Comments

@cloke
Copy link

cloke commented Feb 17, 2022

When using the 3.0 classic decorator on a 4.1 app we get this error on our application serializer. Oddly enough on our 3.28 version with the 2.0 decorator we didn't see this error. I've added the @classic decorator to allow the app to load, but seems like this is a mistake.

Error: You defined the class <my-app@serializer:application::constructor> that extends from EmberObject using native class syntax, but you didn't mark it with the @classic decorator. All user classes that extend from this class must be marked as @classic, since they use classic features. If you want to remove the @classic decorator, you must remove the base class. For components, you can do this by converting to Glimmer components. For plain classes that extend from EmberObject, you can convert them into plain native classes that do not extend from EmberObject.

If this class is a base class provided by the framework that you should be allowed to remove @classic from, please open an issue on the classic decorators repo: https://github.com/emberjs/ember-classic-decorator
@kategengler
Copy link
Member

I just encountered this on 3.28 with 3.0 of classic decorator for adapters. I followed the trail back into ember-data and JSONAPIAdapter extends RestAdapter which includes a mixin, so it seems to be correct for that case. Have you followed your ApplicationSerializer inheritance back?

@donaldsonjulia
Copy link

@kategengler I have also just experienced this when extending from my ApplicationAdapter which extends from JSONAPIAdapter. Strangely I don't get the error on ApplicationAdapter extending from JSONAPIAdapter, but I do get the error when I extend from ApplicationAdapter.

I also followed the trail back and I see what you are saying about RestAdapter and the mixin....so are you suggesting that this is expected behavior? The only reason it seems odd to me is that we are using "ember-data": "~4.4.0" with "ember-source": "~4.4.0" and in new CLI outputs for 4.4.0, the classic decorator package is not included. It seems odd to have an app-breaking error in this case. If I reduce all other usage of the @classic decorator to this one instance in my app, do I have to keep using it until another version of Ember Data is released?

Thanks so much for your help in clarifying!

@kategengler
Copy link
Member

I don't believe ember-classic-decorator was ever default (ever in the blueprints).

I believe that when using this addon, that error is correct and the @classic decorator is warranted, because it is ultimately a classic-style class.

If you don't have this addon in your app, this error should not occur and everything should work, since this addon is dev-only and for guidance upgrading only.

I cannot explain why it doesn't happen in the ApplicationAdapter.

@kategengler
Copy link
Member

@emberjs/ember-data-core any ideas?

@donaldsonjulia
Copy link

Thanks so much!! I think my main confusion was that our upgrade path was to reduce the usage of ember-classic-decorator to zero without errors before finally removing it as a dependency.

Just to extra confirm for anyone else stumbling on this issue: Are you saying that if this is the last instance in our app where the error is thrown (because of extending framework-supplied JSONAPIAdapter and JSONAPISerializer), we can safely remove the addon altogether? From a consumer standpoint, we don't need to care about the inheritance back to RestAdapter being classic and we can write code using only Octane/native-class syntax? (Assuming we are using the public APIs and not being hacky with internals)

@kategengler
Copy link
Member

Yes, I believe you can remove it. As you say, newly generated apps do not have ember-classic-decorator but also have working JSONAPIAdapters.

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

No branches or pull requests

3 participants