graphql-client 0.11.3 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1f249768903f7c19d50d767cde9477fe3c40856
4
- data.tar.gz: 533ec338472652dd2c9de670f69eebf5f2acf408
3
+ metadata.gz: fa036bb50b5ab41d9e3d73053cf1d37141797885
4
+ data.tar.gz: 41635ac628917be0f1babb56436aab27eb89fbf3
5
5
  SHA512:
6
- metadata.gz: a8d0ba14057afdeb80ed7a688861b2e69b999dbd753e8354dd0eb66dd7fd57c69984a74d13cb35e64d89211e0e7be0e5e6c5b71576fcec9667242a6ce2537d36
7
- data.tar.gz: 71d1946d1cc42a397acb3c9ae73f2034c65d1f799927f344c3dcf4341bbb0acb2dcd97089ee6126a2b5b80e4e733da776722bcaf8df6831d7d3bd9c2f9a16bca
6
+ metadata.gz: 71597a7fb1ab438970d8bf4e16041c8150d58a42860a89b077bb56d361e901bb935bd54efebc4549ac3fa82f6217993dbe00ed24e0d97d5442bd6b50a5918ede
7
+ data.tar.gz: 19ff47eef9b1b5dae74f28cb246b080f7098b8a7d5d45a3322ed2c9c0c34012b7c5d3e74d3f215cc786f13fb206e43af0258f805b05fadf41e8b65b822a4216b
data/README.md CHANGED
@@ -20,7 +20,7 @@ module SWAPI
20
20
  # Fetch latest schema on init, this will make a network request
21
21
  Schema = GraphQL::Client.load_schema(HTTP)
22
22
 
23
- # However, its smart to dump this to a JSON file and load from disk
23
+ # However, it's smart to dump this to a JSON file and load from disk
24
24
  #
25
25
  # Run it from a script or rake task
26
26
  # GraphQL::Client.dump_schema(SWAPI::HTTP, "path/to/schema.json")
@@ -114,7 +114,7 @@ module GraphQL
114
114
 
115
115
  definition_dependencies = Set.new
116
116
 
117
- str = str.gsub(/\.\.\.([a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)*)/) do
117
+ str = str.gsub(/\.\.\.([a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)*)$/) do
118
118
  match = Regexp.last_match
119
119
  const_name = match[1]
120
120
 
@@ -317,9 +317,12 @@ module GraphQL
317
317
  )
318
318
  end
319
319
 
320
+ deep_freeze_json_object(result)
321
+
320
322
  data, errors, extensions = result.values_at("data", "errors", "extensions")
321
323
 
322
324
  errors ||= []
325
+ errors = errors.map(&:dup)
323
326
  GraphQL::Client::Errors.normalize_error_paths(data, errors)
324
327
 
325
328
  errors.each do |error|
@@ -328,6 +331,7 @@ module GraphQL
328
331
  end
329
332
 
330
333
  Response.new(
334
+ result,
331
335
  data: definition.new(data, Errors.new(errors, ["data"])),
332
336
  errors: Errors.new(errors),
333
337
  extensions: extensions
@@ -344,6 +348,19 @@ module GraphQL
344
348
 
345
349
  private
346
350
 
351
+ def deep_freeze_json_object(obj)
352
+ case obj
353
+ when String
354
+ obj.freeze
355
+ when Array
356
+ obj.each { |v| deep_freeze_json_object(v) }
357
+ obj.freeze
358
+ when Hash
359
+ obj.each { |k, v| k.freeze; deep_freeze_json_object(v) }
360
+ obj.freeze
361
+ end
362
+ end
363
+
347
364
  def deep_stringify_keys(obj)
348
365
  case obj
349
366
  when Hash
@@ -7,6 +7,12 @@ module GraphQL
7
7
  #
8
8
  # https://facebook.github.io/graphql/#sec-Response-Format
9
9
  class Response
10
+ # Public: Original JSON response hash returned from server.
11
+ #
12
+ # Returns Hash.
13
+ attr_reader :original_hash
14
+ alias_method :to_h, :original_hash
15
+
10
16
  # Public: Wrapped ObjectType of data returned from the server.
11
17
  #
12
18
  # https://facebook.github.io/graphql/#sec-Data
@@ -25,7 +31,8 @@ module GraphQL
25
31
  attr_reader :extensions
26
32
 
27
33
  # Internal: Initialize base class.
28
- def initialize(data: nil, errors: Errors.new, extensions: {})
34
+ def initialize(hash, data: nil, errors: Errors.new, extensions: {})
35
+ @original_hash = hash
29
36
  @data = data
30
37
  @errors = errors
31
38
  @extensions = extensions
@@ -46,7 +46,7 @@ module GraphQL
46
46
  def eager_load!
47
47
  return unless File.directory?(load_path)
48
48
 
49
- Dir.entries(load_path).each do |entry|
49
+ Dir.entries(load_path).sort.each do |entry|
50
50
  next if entry == "." || entry == ".."
51
51
  name = entry.sub(/(\.\w+)+$/, "").camelize.to_sym
52
52
  if ViewModule.valid_constant_name?(name)
@@ -97,7 +97,7 @@ module GraphQL
97
97
  # Returns new Module implementing Loadable concern.
98
98
  def load_module(name)
99
99
  pathname = ActiveSupport::Inflector.underscore(name.to_s)
100
- path = Dir[File.join(load_path, "{#{pathname},_#{pathname}}{.*}")].map { |fn| File.expand_path(fn) }.first
100
+ path = Dir[File.join(load_path, "{#{pathname},_#{pathname}}{.*}")].sort.map { |fn| File.expand_path(fn) }.first
101
101
 
102
102
  return if !path || File.extname(path) != ".erb"
103
103
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.5'
39
+ version: '1.6'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.5'
46
+ version: '1.6'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: actionpack
49
49
  requirement: !ruby/object:Gem::Requirement