Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby GraphQL: Custom Scalar Hash

Ruby GraphQL: Custom Scalar Hash

module CustomScalars
  class Hash < GraphQL::Schema::Scalar
    description 'Represents a regular hash.'
  end
end
module Mutations
  class UpdateUser < Base
    argument :user_properties, [CustomScalars::Hash], required: true
  end
end
module Types
  class User < GraphQL::Schema::Object
    field :user_properties, CustomScalars::Hash, null: true
  end
end

Now we can mutate and query the user_properties attribute as a regular hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.