GithubHelp home page GithubHelp logo

apollo_upload_server-ruby's People

Contributors

alan-marx avatar bastengao avatar bdubaut avatar cooperka avatar d4rky-pl avatar dependabot[bot] avatar fuelen avatar ham0215 avatar hsbt avatar jjb avatar lukes avatar oriolgual avatar pauljacksonrodgers avatar qwyng avatar rasmushaarslev avatar satom9to5 avatar sguha00 avatar usernam3 avatar utkarsh2102 avatar yiyidai avatar yoshoku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

apollo_upload_server-ruby's Issues

2.1.1 is Incompatible with Rails 7

I was trying to upgrade from 2.1.0 to 2.1.1, and I'm getting this error:

Bundler could not find compatible versions for gem "actionpack":
  In snapshot (Gemfile.lock):
    actionpack (>= 7.0.3.1)

  In Gemfile:
    apollo_upload_server (~> 2.1, >= 2.1.1) was resolved to 2.1.1, which depends on
      actionpack (~> 6.1)

    rails (~> 7.0, >= 7.0.2.3) was resolved to 7.0.3.1, which depends on
      actionpack (= 7.0.3.1)

Deleting your Gemfile.lock file and running `bundle install` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Been using 2.1.0 for awhile now with Rails 7, it's working great :D

How should we be testing mutations that accept uploaded files in 2.1.5?

I'm in the process of upgrading an app from 2.0.1 to 2.1.5 and all the tests we have involving uploaded files are now failing with an "#Rack::Test::UploadedFiles... is not a valid upload" error. In our tests we're creating these files using a helper method:

module UploadTestHelper
  def generic_file
    Rack::Test::UploadedFile.new(Rails.root.join("spec", "data", "test_attachment.txt"))
  end
end

and then we're using it anywhere we need a file in the tests:

let(:variables) do
  {
    input: {
      quoteId: quote.id,
      files: [UploadTestHelper.quote],
    }
  }
end

This was working as expected until now, but after upgrading to 2.1.5 these test files are being rejected. I can't see any documentation on how to create test files. I've tracked down the issue to this change - https://github.com/jetruby/apollo_upload_server-ruby/pull/32/files. Is it possible to get an example of how to use this Wrappers::UploadedFile class to wrap up a local file for specs please? I've tried a few things and haven't managed to get anything working.

uninitialized constant ApolloUploadServer::Rails on Heroku

I get the following error when trying to initialize the console on Heroku

Running console on ⬢ REMOVED... up, run.3428 (Hobby)
Traceback (most recent call last):
	7: from /app/vendor/bundle/bin/console:29:in `<main>'
	6: from /app/vendor/bundle/bin/console:29:in `load'
	5: from /app/vendor/bundle/ruby/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/bin/console:4:in `<top (required)>'
	4: from /app/vendor/bundle/ruby/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/bin/console:4:in `require'
	3: from /app/vendor/bundle/ruby/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/lib/apollo_upload_server.rb:4:in `<top (required)>'
	2: from /app/vendor/bundle/ruby/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/lib/apollo_upload_server.rb:4:in `require'
	1: from /app/vendor/bundle/ruby/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/lib/apollo_upload_server/railtie.rb:3:in `<top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/lib/apollo_upload_server/railtie.rb:4:in `<module:ApolloUploadServer>': uninitialized constant ApolloUploadServer::Rails (NameError)

Unfortunately, I can reproduce it locally 😢

This is running Rails 6 on the Heroku 18 stack

Not compatible with graphql gem >= v1.10.0

Hi, thank you for creating this file uploading type. Unfortunately, it does not seem to work with current versions of the graphql Ruby gem. I'm seing this stacktrace when I try to update graphql:

rails_1        | ArgumentError: Can't add legacy type: Upload (GraphQL::ScalarType)
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1767:in `add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1811:in `block in add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1808:in `each'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1808:in `add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1811:in `block in add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1808:in `each'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1808:in `add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1803:in `block (2 levels) in add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1800:in `each'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1800:in `block in add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1796:in `each'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1796:in `add_type'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1673:in `block in add_type_and_traverse'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1673:in `each'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:1673:in `add_type_and_traverse'
rails_1        | /bundle/ruby/2.6.0/gems/graphql-1.10.2/lib/graphql/schema.rb:972:in `mutation'

Support for bundler >= 2.x?

Hi,

Thank you for your awesome work, however this library fails to build with bundler > 2.x.
Bundler 2.1.4 was recently released. Could we have support for that, too? :)

recent PR with a breaking change

PR: #51

This PR requires the gem users to have rails 7. Maybe the gem should bump a major version to reflect that breaking change? Are you not longer going to support rails 6.x?

Middleware not working

As far as I can tell, the middleware does not seem to be working as intended.

When submitting using apollo-upload-client I get the operations parameter in the request parameters, but the GraphQL server does not know what to do with it. Isn't that what the middleware is supposed to do?

My graphql_controller#execute method looks like this:

def execute
  variables = prepare_variables(params[:variables])
  query = params[:query]
  operation_name = params[:operationName]
  context = {
    # Query context goes here, for example:
    # current_user: current_user,
  }
  result = MySchema.execute(
    query,
    variables: variables,
    context: context,
    operation_name: operation_name
  )
  render json: result
rescue StandardError => e
  raise e unless Rails.env.development?

  handle_error_in_development(e)
end

Using:

  • Rails 6.1.4.1
  • GraphQL-ruby 1.12.14
  • apollo_upload_server 2.1.0

Middleware not updating the request with correct params

First of all thanks for the middleware @jetruby. Appreciate it.

Shouldn't the middleware update request.params['operations'] instead of request.

Because, result = GraphQLDataBuilder.new.call(request.params) returns value for request.params['operations']

related gems

  • graphql (1.8.0.pre6)
  • apollo_upload_server (= 2.0.0.beta.1)

Using this in 2020

Is anyone using this in production? Specifically in coordination with https://github.com/jaydenseric/apollo-upload-client

If so, it would be awesome if someone could share an example!

The best 2 posts I have found covering this are:

My current issue is: I can get the file to attach when I write the query in Insomnia, but in the browser I can an error: Error: GraphQL error: Variable $file of type Upload! was provided invalid value. Happy to provide more context on this specific bug if someone thinks that would be helpful!

If there is a fix, also happy to help submit it back as a PR (assuming I can figure this out)

Support for Rails <5.0?

My application is on 4.2.8 and we won't be upgrading any time in the near future -- does this gem have to have a hard 5.0+ dependency, or can it be loosened?

Testing upload within graphql-ruby

Hi 👋

I'm trying to write tests for my rmosolgo/graphql-ruby project, and I don't know how I can prepare a file to be passed as variables to MySchema.execute within a rspec example, so I can test my upload mutation.

I tried looking at the specs of this project, but had no luck.

I also asked there: rmosolgo/graphql-ruby#2146 with some more details.

Feature Request: Uploading Files to Association's Record Without Removing Old Ones

Problem

Currently, when uploading files to an association's record using the ApolloUploadServer::Upload type, the old files are removed, which may not be the desired behavior for all use cases. This makes it challenging to append new files to an existing collection of files associated with a record.

Desired Behavior

I would like to request a new feature that allows uploading files to an association's record without removing the old ones. Instead, the new files should be appended to the existing collection of files.

Implementation Details

As a user, I would expect to be able to upload a new file to an association's record while preserving the old files. This can help in scenarios where multiple files need to be associated with a single record.

Example

Here is an example of the current argument definition:

argument :pictures, ApolloUploadServer::Upload, required: false,
         prepare: -> (file, _ctx) { create_blob(file) }, description: "It accepts a File object."

v2.0.2 breaks specs using fixture_file_upload

The latest version of this gem (v2.0.2) included this Pull Request that raises an error on type mismatch. This causes issues with spec that leverage the fixture_file_upload method. When using fixture_file_upload, the value argument passed to the coerce_input method is of type ActionDispatch::Http::UploadedFile not ApolloUploadServer::Wrappers::UploadedFile, so the GraphQL::CoercionError is raised. Since ApolloUploadServer::Wrappers::UploadedFile is a delegate class of ActionDispatch::Http::UploadedFile everything works fine without the type check.

Example Spec

The mutation takes a file, and returns true if the upload was successful

def query
    <<~GQL
      mutation($file: Upload!) {
        uploadCsv(file: $file)
      }
    GQL
end

let(:variables) do
  {  file: fixture_file_upload(Rails.root.join('spec', 'fixtures', 'file.csv'), 'text/csv') }
end

it 'returns a true' do
  post '/graphql', params: { query: query, variables: variables }
  expect(JSON.parse(response.body)['data']['uploadCsv']).to eq true
end

I pulled the gem down to see I could resolve the issue, but the only thing I could come up with is to remove the prior change or add an additional is_a? check for ActionDispatch::Http::UploadedFile.

Has anyone else ran into this issue? Is there a different way to define a spec to get around this?

uninitialized constant ApolloUploadServer::GraphQL

I installed the gem by adding it to my gemfile and ran bundler as per the README. When starting the server I get the following error message:

/usr/share/rvm/rubies/ruby-2.4.1/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/rasmus/Documents/statum/API/bin/rails server -b 0.0.0.0 -p 3001 -e development
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'apollo_upload_server'. (Bundler::GemRequireError)
Gem Load Error is: uninitialized constant ApolloUploadServer::GraphQL
Backtrace for gem load error is:
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/apollo_upload_server-2.0.0.alpha.2/lib/apollo_upload_server/upload.rb:2:in `<module:ApolloUploadServer>'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/apollo_upload_server-2.0.0.alpha.2/lib/apollo_upload_server/upload.rb:1:in `<top (required)>'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/apollo_upload_server-2.0.0.alpha.2/lib/apollo_upload_server.rb:5:in `require'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/apollo_upload_server-2.0.0.alpha.2/lib/apollo_upload_server.rb:5:in `<top (required)>'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `require'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler.rb:114:in `require'
/home/rasmus/Documents/statum/API/config/application.rb:19:in `<top (required)>'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `require'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `block in server'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
/home/rasmus/Documents/statum/API/bin/rails:9:in `require'
/home/rasmus/Documents/statum/API/bin/rails:9:in `<top (required)>'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/usr/share/rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/usr/share/rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/home/rasmus/Documents/statum/API/bin/spring:14:in `<top (required)>'
/home/rasmus/Documents/statum/API/bin/rails:3:in `load'
/home/rasmus/Documents/statum/API/bin/rails:3:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
Bundler Error Backtrace:
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:80:in `block (2 levels) in require'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler.rb:114:in `require'
	from /home/rasmus/Documents/statum/API/config/application.rb:19:in `<top (required)>'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `require'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `block in server'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
	from /home/rasmus/Documents/statum/API/bin/rails:9:in `require'
	from /home/rasmus/Documents/statum/API/bin/rails:9:in `<top (required)>'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
	from /home/rasmus/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
	from /usr/share/rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/share/rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /home/rasmus/Documents/statum/API/bin/spring:14:in `<top (required)>'
	from /home/rasmus/Documents/statum/API/bin/rails:3:in `load'
	from /home/rasmus/Documents/statum/API/bin/rails:3:in `<top (required)>'
	from -e:1:in `load'
	from -e:1:in `<main>'

Process finished with exit code 1

I'm running

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

with the following gems:

Gems included by the bundle:
  * actioncable (5.0.6)
  * actionmailer (5.0.6)
  * actionpack (5.0.6)
  * actionview (5.0.6)
  * activejob (5.0.6)
  * activemodel (5.0.6)
  * activerecord (5.0.6)
  * activesupport (5.0.6)
  * addressable (2.5.2)
  * analytics-ruby (2.0.13)
  * apollo_upload_server (2.0.0.alpha.2)
  * arel (7.1.4)
  * ast (2.4.0)
  * aws-partitions (1.61.0)
  * aws-sdk (3.0.1)
  * aws-sdk-acm (1.3.0)
  * aws-sdk-alexaforbusiness (1.1.0)
  * aws-sdk-apigateway (1.9.0)
  * aws-sdk-applicationautoscaling (1.7.0)
  * aws-sdk-applicationdiscoveryservice (1.1.0)
  * aws-sdk-appstream (1.5.0)
  * aws-sdk-appsync (1.0.0)
  * aws-sdk-athena (1.0.0)
  * aws-sdk-autoscaling (1.4.0)
  * aws-sdk-autoscalingplans (1.1.0)
  * aws-sdk-batch (1.3.0)
  * aws-sdk-budgets (1.5.0)
  * aws-sdk-cloud9 (1.1.0)
  * aws-sdk-clouddirectory (1.1.0)
  * aws-sdk-cloudformation (1.3.0)
  * aws-sdk-cloudfront (1.1.0)
  * aws-sdk-cloudhsm (1.3.0)
  * aws-sdk-cloudhsmv2 (1.1.0)
  * aws-sdk-cloudsearch (1.0.0)
  * aws-sdk-cloudsearchdomain (1.0.0)
  * aws-sdk-cloudtrail (1.0.0)
  * aws-sdk-cloudwatch (1.4.0)
  * aws-sdk-cloudwatchevents (1.1.0)
  * aws-sdk-cloudwatchlogs (1.2.0)
  * aws-sdk-codebuild (1.6.0)
  * aws-sdk-codecommit (1.2.0)
  * aws-sdk-codedeploy (1.3.0)
  * aws-sdk-codepipeline (1.1.0)
  * aws-sdk-codestar (1.1.0)
  * aws-sdk-cognitoidentity (1.0.0)
  * aws-sdk-cognitoidentityprovider (1.3.0)
  * aws-sdk-cognitosync (1.0.0)
  * aws-sdk-comprehend (1.0.0)
  * aws-sdk-configservice (1.5.0)
  * aws-sdk-core (3.15.0)
  * aws-sdk-costandusagereportservice (1.0.0)
  * aws-sdk-costexplorer (1.0.0)
  * aws-sdk-databasemigrationservice (1.4.0)
  * aws-sdk-datapipeline (1.0.0)
  * aws-sdk-dax (1.0.0)
  * aws-sdk-devicefarm (1.3.0)
  * aws-sdk-directconnect (1.1.0)
  * aws-sdk-directoryservice (1.1.0)
  * aws-sdk-dynamodb (1.4.0)
  * aws-sdk-dynamodbstreams (1.0.0)
  * aws-sdk-ec2 (1.27.0)
  * aws-sdk-ecr (1.2.0)
  * aws-sdk-ecs (1.8.0)
  * aws-sdk-efs (1.0.0)
  * aws-sdk-elasticache (1.3.0)
  * aws-sdk-elasticbeanstalk (1.3.0)
  * aws-sdk-elasticloadbalancing (1.2.0)
  * aws-sdk-elasticloadbalancingv2 (1.7.0)
  * aws-sdk-elasticsearchservice (1.3.0)
  * aws-sdk-elastictranscoder (1.0.0)
  * aws-sdk-emr (1.1.0)
  * aws-sdk-firehose (1.1.0)
  * aws-sdk-gamelift (1.2.0)
  * aws-sdk-glacier (1.6.0)
  * aws-sdk-glue (1.5.0)
  * aws-sdk-greengrass (1.2.0)
  * aws-sdk-guardduty (1.2.0)
  * aws-sdk-health (1.0.0)
  * aws-sdk-iam (1.3.0)
  * aws-sdk-importexport (1.0.0)
  * aws-sdk-inspector (1.3.0)
  * aws-sdk-iot (1.3.0)
  * aws-sdk-iotdataplane (1.0.0)
  * aws-sdk-iotjobsdataplane (1.0.0)
  * aws-sdk-kinesis (1.2.0)
  * aws-sdk-kinesisanalytics (1.2.0)
  * aws-sdk-kinesisvideo (1.0.0)
  * aws-sdk-kinesisvideoarchivedmedia (1.0.0)
  * aws-sdk-kinesisvideomedia (1.0.0)
  * aws-sdk-kms (1.5.0)
  * aws-sdk-lambda (1.4.0)
  * aws-sdk-lambdapreview (1.0.0)
  * aws-sdk-lex (1.3.0)
  * aws-sdk-lexmodelbuildingservice (1.4.0)
  * aws-sdk-lightsail (1.3.0)
  * aws-sdk-machinelearning (1.0.0)
  * aws-sdk-marketplacecommerceanalytics (1.0.0)
  * aws-sdk-marketplaceentitlementservice (1.0.0)
  * aws-sdk-marketplacemetering (1.0.0)
  * aws-sdk-mediaconvert (1.0.0)
  * aws-sdk-medialive (1.2.0)
  * aws-sdk-mediapackage (1.0.0)
  * aws-sdk-mediastore (1.1.0)
  * aws-sdk-mediastoredata (1.1.0)
  * aws-sdk-migrationhub (1.0.0)
  * aws-sdk-mobile (1.0.0)
  * aws-sdk-mq (1.0.0)
  * aws-sdk-mturk (1.2.0)
  * aws-sdk-opsworks (1.2.0)
  * aws-sdk-opsworkscm (1.2.0)
  * aws-sdk-organizations (1.7.0)
  * aws-sdk-pinpoint (1.2.0)
  * aws-sdk-polly (1.4.0)
  * aws-sdk-pricing (1.0.0)
  * aws-sdk-rds (1.12.0)
  * aws-sdk-redshift (1.1.0)
  * aws-sdk-rekognition (1.2.0)
  * aws-sdk-resourcegroups (1.0.0)
  * aws-sdk-resourcegroupstaggingapi (1.0.0)
  * aws-sdk-resources (3.12.0)
  * aws-sdk-route53 (1.8.0)
  * aws-sdk-route53domains (1.1.0)
  * aws-sdk-s3 (1.8.0)
  * aws-sdk-sagemaker (1.5.0)
  * aws-sdk-sagemakerruntime (1.0.0)
  * aws-sdk-serverlessapplicationrepository (1.0.0)
  * aws-sdk-servicecatalog (1.3.0)
  * aws-sdk-servicediscovery (1.1.0)
  * aws-sdk-ses (1.6.0)
  * aws-sdk-shield (1.1.0)
  * aws-sdk-simpledb (1.0.0)
  * aws-sdk-sms (1.0.0)
  * aws-sdk-snowball (1.2.0)
  * aws-sdk-sns (1.1.0)
  * aws-sdk-sqs (1.3.0)
  * aws-sdk-ssm (1.7.0)
  * aws-sdk-states (1.2.0)
  * aws-sdk-storagegateway (1.2.0)
  * aws-sdk-support (1.0.0)
  * aws-sdk-swf (1.0.0)
  * aws-sdk-transcribeservice (1.0.0)
  * aws-sdk-translate (1.0.0)
  * aws-sdk-waf (1.3.0)
  * aws-sdk-wafregional (1.3.0)
  * aws-sdk-workdocs (1.1.0)
  * aws-sdk-workmail (1.0.0)
  * aws-sdk-workspaces (1.1.0)
  * aws-sdk-xray (1.1.0)
  * aws-sigv2 (1.0.1)
  * aws-sigv4 (1.0.2)
  * bcrypt (3.1.11)
  * bindex (0.5.0)
  * builder (3.2.3)
  * bullet (5.7.2)
  * bundler (1.16.1)
  * byebug (10.0.0)
  * callsite (0.0.11)
  * capybara (2.18.0)
  * choice (0.2.0)
  * climate_control (0.2.0)
  * cocaine (0.5.8)
  * coderay (1.1.2)
  * coffee-rails (4.2.2)
  * coffee-script (2.4.1)
  * coffee-script-source (1.12.2)
  * concurrent-ruby (1.0.5)
  * crack (0.4.3)
  * crass (1.0.3)
  * css_parser (1.6.0)
  * database_cleaner (1.6.2)
  * devise (4.4.1)
  * diff-lcs (1.3)
  * discard (0.2.0)
  * docile (1.1.5)
  * erubis (2.7.0)
  * execjs (2.7.0)
  * factory_bot (4.8.2)
  * factory_bot_rails (4.8.2)
  * faraday (0.12.2)
  * ffi (1.9.21)
  * formatador (0.2.5)
  * foundation_emails (2.2.1.0)
  * globalid (0.4.1)
  * google_maps_service (0.4.2)
  * graphiql-rails (1.4.8)
  * graphql (1.7.12)
  * graphql-errors (0.1.0)
  * graphql-query-resolver (0.2.0)
  * guard (2.14.2)
  * guard-compat (1.2.1)
  * guard-rspec (4.7.3)
  * hashdiff (0.3.7)
  * hashie (3.5.7)
  * htmlentities (4.3.4)
  * httparty (0.16.0)
  * hubspot-ruby (0.4.0)
  * hurley (0.2)
  * i18n (0.9.5)
  * inky-rb (1.3.7.2)
  * jbuilder (2.7.0)
  * jmespath (1.3.1)
  * jquery-rails (4.3.1)
  * json (2.1.0)
  * jwt (1.5.6)
  * launchy (2.4.3)
  * letter_opener (1.6.0)
  * letter_opener_web (1.3.3)
  * linkedin-oauth2 (1.0.0)
  * listen (3.0.8)
  * lograge (0.9.0)
  * loofah (2.2.0)
  * lumberjack (1.0.12)
  * mail (2.7.0)
  * meta_request (0.5.0)
  * method_source (0.9.0)
  * mime-types (3.1)
  * mime-types-data (3.2016.0521)
  * mimemagic (0.3.2)
  * mini_mime (1.0.0)
  * mini_portile2 (2.3.0)
  * minitest (5.11.3)
  * multi_json (1.13.1)
  * multi_xml (0.6.0)
  * multipart-post (2.0.0)
  * nenv (0.3.0)
  * nio4r (2.2.0)
  * nokogiri (1.8.2)
  * notiffany (0.1.1)
  * oauth2 (1.4.0)
  * orm_adapter (0.5.0)
  * paperclip (5.0.0)
  * parallel (1.12.1)
  * parser (2.4.0.2)
  * pg (0.21.0)
  * powerpack (0.1.1)
  * premailer (1.11.1)
  * premailer-rails (1.10.1)
  * pry (0.11.3)
  * public_suffix (3.0.2)
  * puma (3.11.2)
  * pundit (1.1.0)
  * pundit-matchers (1.4.1)
  * rack (2.0.4)
  * rack-contrib (2.0.1)
  * rack-cors (1.0.2)
  * rack-rewrite (1.5.1)
  * rack-test (0.6.3)
  * rails (5.0.6)
  * rails-controller-testing (1.0.2)
  * rails-dom-testing (2.0.3)
  * rails-erd (1.5.2)
  * rails-html-sanitizer (1.0.3)
  * railties (5.0.6)
  * rainbow (3.0.0)
  * rake (12.3.0)
  * rb-fsevent (0.10.2)
  * rb-inotify (0.9.10)
  * redis (4.0.1)
  * redis-actionpack (5.0.2)
  * redis-activesupport (5.0.4)
  * redis-rack (2.0.4)
  * redis-rails (5.0.2)
  * redis-store (1.4.1)
  * request_store (1.4.0)
  * responders (2.4.0)
  * retriable (2.1.0)
  * rspec (3.7.0)
  * rspec-core (3.7.1)
  * rspec-expectations (3.7.0)
  * rspec-graphql_matchers (0.7.1)
  * rspec-mocks (3.7.0)
  * rspec-rails (3.7.2)
  * rspec-support (3.7.1)
  * rubocop (0.52.1)
  * ruby-graphviz (1.2.3)
  * ruby-prof (0.17.0)
  * ruby-progressbar (1.9.0)
  * safe_yaml (1.0.4)
  * sass (3.5.5)
  * sass-listen (4.0.0)
  * sass-rails (5.0.7)
  * search_object (1.2.0)
  * search_object_graphql (0.1)
  * sentry-raven (2.7.2)
  * shellany (0.0.1)
  * shoulda-matchers (3.1.2)
  * simplecov (0.15.1)
  * simplecov-html (0.10.2)
  * spawnling (2.1.6)
  * spring (2.0.2)
  * spring-commands-rspec (1.0.4)
  * spring-watcher-listen (2.0.1)
  * sprockets (3.7.1)
  * sprockets-rails (3.2.1)
  * stripe (3.9.2)
  * thor (0.20.0)
  * thread_safe (0.3.6)
  * tilt (2.0.8)
  * turbolinks (5.1.0)
  * turbolinks-source (5.1.0)
  * tzinfo (1.2.5)
  * uglifier (4.1.6)
  * unicode-display_width (1.3.0)
  * uniform_notifier (1.11.0)
  * vcr (4.0.0)
  * warden (1.2.7)
  * web-console (3.5.1)
  * webmock (3.3.0)
  * websocket-driver (0.6.5)
  * websocket-extensions (0.1.3)
  * wisper (2.0.0)
  * xpath (3.0.0)

ActionDispatch::Http::UploadedFile received as ActionController::Parameters in rspec tests

I am writing a mutation that that includes file upload and spec fails throwing the error below
[{"extensions"=>{"problems"=>[{"explanation"=>"#<ActionController::Parameters {\"original_filename\"=...0x0000aaaaf8b0e868>\", \"content_type\"=>\"image/jpeg\"} permitted: false> is not a valid upload)"}].
I dug a bit further and found out that the file I passed was received as ActionController::parameters rather than ActionDispatch::Http::UploadedFile. Below is how I wrote the mutation in the spec

create_mutation = <<~GQL mutation createItem( $shortDescription: String! $image: Upload! ) { createItem( shortDescription: $shortDescription images: $images ) { id } } GQL

variables = { image: ::ApolloUploadServer::Wrappers::UploadedFile.new(ActionDispatch::Http::UploadedFile.new(filename: "image.png", type: "image/png", tempfile: File.new("spec/support/fixtures/image.png"))) }

response = ApiSchema.execute(create_mutation, variables: variables })

New coerce_input class type check breaks tests

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.

Non-middleware usage?

We have a fairly large app that only exposes GraphQL on one endpoint, but has a bunch of other controllers.

It seems wasteful to add an extra middleware just for that, have you considered separating the middleware/railtie parts from the "library" usage ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.