-
Notifications
You must be signed in to change notification settings - Fork 147
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
Is it possible to use ja_serializer with a newly generated Phoenix 1.7.7 app? #346
Comments
P.S. This other issue might suggest a solution (ie. removing dependency on |
I'm currently using JaSerializer on a Phoenix 1.7.3 app and haven't run into any issues. Is there something specific about 1.7.7 that breaks it? I haven't had a chance to try it with the newest version, but I would be surprised if there was a backwards incompatibility. The issue you posted to in your second comment is more about removing What errors are you running into? |
@beerlington Ahhh, thanks for the clarification on |
@beerlington Okay, I'm back with two example repos...
All you need to do in either repo is run
All there is in each repo is a thing controller (which is a singleton and only has a show action) and a thing controller test. Suspected Reason
Or am I misunderstanding something here? And thanks again for all your help! |
@theirishpenguin Thanks for the examples. I think the immediate issue is the use of |
@beerlington Thanks. Yes, I think that newly generated phoenix 1.7.7 apps don't have this I am guessing my conservative option is to generate a phoenix 1.6.X app and upgrade it to phoenix 1.7.7 (as Jose seems to have suggested in the workaround in my original description). But, then we'll all still have a problem when we try to create new phoenix apps with phoenix 1.7.7 and future versions of phoenix. And I'm interested to know if there are any JA serializer plans to work to improve phoenix 1.7.7 integration (or if anything needs to change). Put another way, what needs to change in the JA Serializer README example to work with phoenix 1.7.7? (Is the above example now obsolete in terms of the latest Phoenix release?) Thanks for all your help. Really appreciate it. |
That's a good question about how to move forward. The docs you linked to in your first comment say this:
It doesn't sound like |
Great to get your above input @beerlington , cheers!
Yes, indeed 👍
As an experiment (and with very little knowledge of the new Component/Template approach in the latest Phoenix), I have managed to get my broken phoenix 1.7.7 example working with ja_serializer for a basic scenario theirishpenguin/example_17x_app#3 It is quite hacky, but I wonder if this illustrates that there may be a reasonable path towards using ja_serializer with phoenix 1.7.7 without bringing in the |
What you've got in your pull request makes sense to me. As I mentioned in your example app PR, having to override the type will be required because we try to infer the type from the module name by default. I wonder if there's a way to override the module name that Phoenix is looking for so you don't have to use a name like |
@beerlington That's great advice, thanks. I've just tried it out at theirishpenguin/example_17x_app#4 and it seems to work a treat. Also fixes the inferring of the "type" getting rid of the Do you see any reason why this kind of approach should not be used in production? (No pressure 😄 ) |
Nope, I think this is a perfectly valid approach. If you have a lot of controllers, it might get a little repetitive. But there are ways to DRY that up so it's easier to maintain. |
Great to hear that @beerlington! I think we can bring the curtains down on this one. I have created a single PR to illustrate how someone can use the above approach to bring ja_serializer into a vanilla phoenix 1.7.X project - theirishpenguin/example_17x_app#5 - just in case it might be of use to someone else reading this in future. Thanks again for all the help. Very impressed with how quickly you replied and I've learned at lot from your advice 🙌 |
The Problem
A newly generated Phoenix 1.7.7 app does not have
Phoenix.View
but ja_serializer depends onPhoenix.View
.From the Phoenix 1.7.7 release announcement...
I've tried a few things but I get a variety of errors no matter what I try.
Is it correct to say that the new
Phoenix.Template
approach of Phoenix 1.7.7 will not currently work with the latest version of ja_serializer? Are there any plans to make ja-serializer integrate with Phoenix 1.7.7?Potential Temporary Workaround
I notice in the Phoenix 1.7.7 upgrade guide that this might be a possibility...
... but going forward that workaround (assuming it even works) would be problematic. It would commit someone, for example when Phoenix 1.9.0 is released, to create a Phoenix 1.6.X and then keep upgrading to 1.9.0.
Any thoughts?
The text was updated successfully, but these errors were encountered: