apollo_upload_server 2.0.0.alpha.4 → 2.0.0.alpha.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of apollo_upload_server might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10005a86d023dffcbe955f801d693d3ba62b7ab1
4
- data.tar.gz: e60aea89cf3a64e889f694e1ac1ddf60fef1d926
3
+ metadata.gz: 4ed7383227bdbba4b75fa53d2c465a3dda76dfcd
4
+ data.tar.gz: 07e38318a8d7ef2f75d8dc9b9a8c77171b7a39cd
5
5
  SHA512:
6
- metadata.gz: 5a15c667570265b4945dae967168b975eba54f32037cfaa608ca1b3b78493f380ddbbecd7b500662016f3a488c7cdb961e5767cf032ce46117ab354652547895
7
- data.tar.gz: 102231ab9e60219d655d6b990542a01cdba6d2990b166615bfe9b8428a124ff51ab0340adc26831f47d7748c597d0dabad6b17ad421348295817feee997e8751
6
+ metadata.gz: 149a08fee3a82a95788fd726e84cd955a13ece377ae59e76a6416a8bd13954ee6847e6deffe25271d1d1c762fff631ee2057068a66e7e783fcb3ae67d4c8d1a7
7
+ data.tar.gz: edc41835dca549f3950d32d998675240c4be0fa4219ed60eb255cfc6105986ffc418f516cc1c91e7466a45c9d2e360e332be9b4653cd10dddf089cf8cfb1178f
data/README.md CHANGED
@@ -9,7 +9,7 @@ use [version 1.0.0](https://github.com/jetruby/apollo_upload_server-ruby/tree/1.
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'apollo_upload_server', '2.0.0.alpha.2'
12
+ gem 'apollo_upload_server', '2.0.0.alpha.5'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
4
+ require 'apollo_upload_server/wrappers/uploaded_file'
2
5
 
3
6
  module ApolloUploadServer
4
7
  class GraphQLDataBuilder
@@ -23,7 +26,8 @@ module ApolloUploadServer
23
26
  splited_path = path.split('.')
24
27
  # splited_path => 'variables.input.profile_photo'; splited_path[0..-2] => ['variables', 'input']
25
28
  # dig from first to penultimate key, and merge last key with value as file
26
- field = operations.dig(*splited_path[0..-2])
29
+
30
+ field = get_parent_field(operations, splited_path)
27
31
  assign_file(field, splited_path, params[file_index])
28
32
  end
29
33
  end
@@ -49,11 +53,27 @@ module ApolloUploadServer
49
53
  nil
50
54
  end
51
55
 
56
+ def get_parent_field(operations, splited_path)
57
+ # returns parent element of file field
58
+
59
+ splited_path[0..-2].inject(operations) do |element, key|
60
+ case element
61
+ when Array
62
+ element[Integer(key)]
63
+ else
64
+ element[key]
65
+ end
66
+ end
67
+ end
68
+
69
+
52
70
  def assign_file(field, splited_path, file)
71
+ wrapped_file = Wrappers::UploadedFile.new(file)
72
+
53
73
  if field.is_a? Hash
54
- field.merge!(splited_path.last => file)
74
+ field.merge!(splited_path.last => wrapped_file)
55
75
  elsif field.is_a? Array
56
- field[splited_path.last.to_i] = file
76
+ field[splited_path.last.to_i] = wrapped_file
57
77
  end
58
78
  end
59
79
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
 
3
5
  module ApolloUploadServer
@@ -1,3 +1,3 @@
1
1
  module ApolloUploadServer
2
- VERSION = '2.0.0.alpha.4'.freeze
2
+ VERSION = '2.0.0.alpha.5'.freeze
3
3
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'delegate'
4
+ require 'action_dispatch/http/upload'
5
+
6
+ module ApolloUploadServer
7
+ module Wrappers
8
+ class UploadedFile < DelegateClass(::ActionDispatch::Http::UploadedFile)
9
+ def initialize(wrapped_foo)
10
+ super
11
+ end
12
+
13
+ def as_json(options = nil)
14
+ instance_values.except('tempfile').as_json(options)
15
+ end
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo_upload_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha.4
4
+ version: 2.0.0.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - JetRuby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -106,6 +106,7 @@ files:
106
106
  - lib/apollo_upload_server/railtie.rb
107
107
  - lib/apollo_upload_server/upload.rb
108
108
  - lib/apollo_upload_server/version.rb
109
+ - lib/apollo_upload_server/wrappers/uploaded_file.rb
109
110
  homepage: https://github.com/jetruby/apollo_upload_server-ruby
110
111
  licenses:
111
112
  - MIT