Netflix / fast_jsonapi

No Longer Maintained - A lightning fast JSON:API serializer for Ruby Objects.
Apache License 2.0
5.07k stars 425 forks source link

Compound documents not showing up #409

Open itsameandrea opened 5 years ago

itsameandrea commented 5 years ago

Hey there guys.

I've been trying to use the compound document serialization, but for some reason things aren't working.

I have a number of models that are being serialized by the gem. This is what they look like:

class Shift < ApplicationRecord
  belongs_to :team, optional: true
  ...
class Team < ApplicationRecord
  has_many :shifts
  ...

This is what the serializer looks like

class ShiftSerializer
  include FastJsonapi::ObjectSerializer
  ...
  belongs_to :team
  ...
end

The serialization works. However, even though I am including the compound team document:

def index
  shifts = policy_scope(Shift)
  options = {}
  options[:include] = [:team, :'team.name', :'team.color']
  render json: ShiftSerializer.new(shifts, options)
end

I'm still getting the object formatted like so:

...
relationships: {
  team: {
    data: {
      id: "22",
      type: "Team"
    }
  }
}

Whereas I'm expecting to get also the attributes of my team model.

1dolinski commented 5 years ago

Did you find a fix for this?

rob-lane commented 5 years ago

Having this exact issue myself... hopefully I can find a fix.

kapilnarula commented 4 years ago

It seems Netflix has abandoned this project. The community created a new fork to continue supporting this project. Please refer https://github.com/fast-jsonapi/fast_jsonapi