Closed jturkel closed 1 year ago
@jturkel Thanks for the PR. This could lead to a big migration for large projects. Is there any way we could make this adoptable on a per-entity basis?
@grxy - That's a fair concern. What about an underscore_reference_keys
DSL method on ApolloFederation::Object
that lets individual entities opt into this behavior e.g.
class User < BaseObject
underscore_reference_keys true
def self.resolve_reference(reference, context)
USERS.find { |user| user[:my_id] == reference[:my_id] }
end
end
This would also allow applications to opt into this behavior for all entities via a BaseObject
superclass:
class BaseObject < GraphQL::Schema::Object
include ApolloFederation::Object
field_class BaseField
underscore_reference_keys true
end
@jturkel I think that approach makes a lot more sense since it allows both incremental and all-at-once adoption. We can talk about it in the future, but we can probably make that behavior the default in a future major release, for consistency with GraphQL Ruby.
@grxy - I switched to using a per-entity setting. Let me know what you think.
:tada: This PR is included in version 3.8.0 :tada:
The release is available on:
v3.8.0
Your semantic-release bot :package::rocket:
This PR adds optional support to underscore the keys in the
_Any
scalar for consistency with thefields
argument of theApolloFederation::Object.key
method and graphql-ruby's general conversion from camelcase to snakecase. I disabled this by default for backwards compatibility but it should probably be enabled by default in the next major release.