Sitelet https://github.com/jsonapi-serializer/jsonapi-serializer/issues/232
Skip to content

Serializer should know if it is serializing as part of a collection or not #232

Description

@GuillaumeMalo

This is not a bug, but it feels like it could provide benefits for very little effort to expose wether or not the record is part of a collection in the serializer.
Benefits include being able to conditionally filter out a costly has_many when in a collection context out of the box.

I know this could be done by either specifying a different serializer for my endpoints serving collection, or passing a custom params hash for every endpoint, but I really see no reason to do so when the information needed already lives inside the scope of serializable_hash.

Expected Behavior

Have access in serializer to wether or not the record is part of a collection.

Actual Behavior

There is no way to know if the record is part of a collection or not.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions