Skip to content

Inertia configuration mismatch when custom prop_transformer #266

@pedrofs

Description

@pedrofs

I'm doing prop_transformer to maintain naming conventions between React and Rails:

  inertia_config prop_transformer: ->(props:) do
                   # We need to parse to JSON and parse back to force ActiveRecord::Base instances to be serialized
                   # otherwise `deep_transform_keys` won't work on their attributes
                   serialized_props = JSON.parse(props.to_json, symbolize_names: true)

                   serialized_props.deep_transform_keys { |key| key.to_s.camelize(:lower) }
                 end

I'm seeing an issue now with merge and deep merge functionality. The deep merge response result comes with snake_case while the prop is camelCase:
Image

I was wondering if we could expose a similar feature as prop_transformer to expose a transformer for the merges. Or, is there a better way to solve this inconsistency?

Thanks!

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