Skip to content

Adding migration section - #139

Merged
stas merged 1 commit into
jsonapi-serializer:masterfrom
guillaumebriday:master
Oct 25, 2020
Merged

Adding migration section#139
stas merged 1 commit into
jsonapi-serializer:masterfrom
guillaumebriday:master

Conversation

@guillaumebriday

@guillaumebriday guillaumebriday commented Oct 22, 2020

Copy link
Copy Markdown
Contributor

What is the new behavior?

Trying to help people to migrate from Netlflix/fast_jsonapi.

Did I forget something ?

@stas

stas commented Oct 22, 2020

Copy link
Copy Markdown
Collaborator

Thanks @guillaumebriday, this is great! 🙇‍♂️

I don't recall anything else (maybe the cache support changes https://github.com/jsonapi-serializer/jsonapi-serializer/pull/52/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)

But I'm happy to merge this as the first step. Let me know if it's ready @guillaumebriday

@guillaumebriday

Copy link
Copy Markdown
Contributor Author

Nice catch, will add it.

Any other suggestion? 🤔

@tonydehnke

Copy link
Copy Markdown
Contributor

My 'base_serializer.rb' file has a line:

require 'fast_jsonapi'

Might be obvious to most, but maybe mention changing it to:
require 'jsonapi-serializer'

@guillaumebriday

Copy link
Copy Markdown
Contributor Author

thanks @tonydehnke I don't need require in my applications, I will update the PR !

@guillaumebriday

Copy link
Copy Markdown
Contributor Author

I think it's ready now 👍

@stas
stas merged commit f4ed4f0 into jsonapi-serializer:master Oct 25, 2020
Comment thread README.md
tonydehnke added a commit to tonydehnke/jsonapi-serializer that referenced this pull request Oct 26, 2020
stas pushed a commit that referenced this pull request Oct 26, 2020
@jrochette

Copy link
Copy Markdown

Hi all, I'm not sure if this is the right place to ask, so let me know and I'll be happy to move this question. I tried migrating from fast_jsonapi today and I hit an issue with relations.
I have this serializer (simplified for the purpose of this example):

class OrganizationSerializer < ApplicationSerializer
  has_many :engagements
  has_many :invites
  [...]
end

Which used to work, but stopped working after migration to jsonapi-serializer 2.1.0. I am now getting this error

NameError:
  OrganizationSerializer cannot resolve a serializer class for 'invite'.  Attempted to find 'InviteSerializer'. Consider specifying the serializer directly through options[:serializer].

As the error indicates, I don't have an InviteSerializer class. I guess this is something that is now required? If so, it should probably be mentioned in the migration doc?

@stas

stas commented Dec 19, 2020

Copy link
Copy Markdown
Collaborator

Hey @jrochette

We had previous reports related to this change, one of them here:
#151 (comment)

Would you be kind to take a look at it and let me know if that makes any sense?! In a nutshell, you might need to specify the serializer inline if it doesn't follow a conventional naming pattern.

@jrochette

Copy link
Copy Markdown

Hey @stas

Thanks for the quick response. I looked at #151 and I don't think it is the same issue, but the explanation does make sense. I agree that it's a good idea to make the serializer resolving rely less on magic.

Just to put more context, I my case, it is not that the serializer is not resolved because of a namespace issue. It doesn't get resolved because it does not exist. I assume there was a mechanism in fast_jsonapi to do something when no serializer was found (some kind of generic serializer maybe?).

We have put our migration to jsonapi-serializer on hold for now, as creating and testing new serializers for models which previsouly had no defined serializer is more work than anticipated. We'll get around to create those serializers eventually. Thanks!

@stas

stas commented Jan 5, 2021

Copy link
Copy Markdown
Collaborator

Just to put more context, I my case, it is not that the serializer is not resolved because of a namespace issue. It doesn't get resolved because it does not exist. I assume there was a mechanism in fast_jsonapi to do something when no serializer was found (some kind of generic serializer maybe?).

That's actually excluded. What could have been the case is that you'd get another/wrong serializer class doing the serialization for you.

Good luck!

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

Successfully merging this pull request may close these issues.

4 participants