Skip to content

New coerce_input class type check breaks tests #37

@mathieugagne

Description

@mathieugagne

I'm trying to upgrade from 2.0.1 to 2.0.3. There was a check added in coerce_input that force the value to be of a certain type. My tests work fine prior to that.

Here's my working solution on 2.0.1

let(:query_string) do
  %|
    mutation($input: UpdateSurveyInput!) {
      updateSurvey(input: $input) {
        id
        clientLogoUrl
      }
    }
  |
end

let(:variables) do
  {
    input: {
      id: survey.id,
      attributes: {
        clientLogo: ActionDispatch::Http::UploadedFile.new(
          filename: "lolcat.png",
          type: "image/png",
          tempfile: File.open(Rails.root.join("spec", "data", "lolcat.png"), "rb")
        )
      }
    }
  }
end

Schema.execute(query, {}, variables)

After 2.0.3 I get the following error:

"#<ActionDispatch::Http::UploadedFile:0x0000562e5512a028 @tempfile=#<File:/home/circleci/project/spec/data/lolcat.png>, @original_filename=\"lolcat.png\", @content_type=\"image/png\", @headers=nil> is not a valid upload"

I tried wrapping my helper in your wrapper class like such:

ApolloUploadServer::Wrappers::UploadedFile.new(filename: "lolcat.png", type: "image/png", tempfile: File.open(Rails.root.join("spec", "data", "lolcat.png"), "rb"),

But it yields a different error:

NoMethodError: undefined method `original_filename' for #<Hash:0x000056250eab5ca0>

Willing to provide more information if needed. Hoping it's a quick fix on your end. I'm unsure why there's a is_a? class check. If it quacks like a duck, it should just be fine. Unsure about the as_json override either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions