cypriss / mutations

Compose your business logic into commands that sanitize and validate input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'model_id' gets passed as 'model', which clashes with similarly named hash.

simonv3 opened this issue · comments

commented

I have a mutation that updates a stage, and is defined as requiring a user, a stage_id (to identify a stage to update), and a hash that contains the optional fields to update.

   required do
      model :user
      string :stage_id

      hash :stage do
        optional do
          string :name
          array :environment
          array :soil
          array :light
          integer :stage_length
        end
      end
    end

When I run the mutation in tests to determine whether an empty mutation returns the right errors: mutation.run({}).errors.message_list

I'm getting these errors:

["User is required", "Stage is required", "Stage is required"]

This seems to be having as effect that when I pass it an id through stage_id as a string, and a hash through stage to update, it will say "Stage is not a string"

When I change the name of stage_id to just id it recognizes it as a required id. Is this a feature that I just don't understand? (I'm pretty new to Ruby on Rails).

As of #129 the _id suffix is preserved, so the errors in the case described above would be:

["User is required", "Stage ID is required", "Stage is required"]