Skip to content

Commit

Permalink
Switch off auto-camelization for GraphQL fields
Browse files Browse the repository at this point in the history
GraphQL Ruby automatically camelises field names [1]. We would like to
switch this off and always use snake casing to match the field names
currently present in content items.

Therefore applying this as a default to all our fields.

1: https://graphql-ruby.org/fields/introduction.html#field-names
  • Loading branch information
brucebolt committed Dec 17, 2024
1 parent b445ba5 commit 4247205
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/graphql/types/base_argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

module Types
class BaseArgument < GraphQL::Schema::Argument
def initialize(*args, camelize: false, **kwargs, &block)
super
end
end
end
4 changes: 4 additions & 0 deletions app/graphql/types/base_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
module Types
class BaseField < GraphQL::Schema::Field
argument_class Types::BaseArgument

def initialize(*args, camelize: false, **kwargs, &block)
super
end
end
end

0 comments on commit 4247205

Please sign in to comment.