graphql 1.6.5 → 1.6.6

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: a043673bcabc1f7cbcc834d71919a4a61dd36a6a
4
- data.tar.gz: efc89423aa48aecce87434a1f0e4567fdf4de290
3
+ metadata.gz: c0462bdcc9e6c3950083b012a0006d25f8013bb0
4
+ data.tar.gz: 0a4e0f3fa8a80fea50c06aaee8b13936d2d08215
5
5
  SHA512:
6
- metadata.gz: d379a08ef187cef29cec03dfb570d3064bc762ff117a5f4e912ef2b5e4cd6f512f1317b42a1e0ae5ccb0510eb505ab36e0ef8ff61c7331326523b7d49889d7d7
7
- data.tar.gz: 58ddefe960ea3e4d75d9c55ba06403632974a796f6fa5a3869977b2733d5dad17e0037390848cdd738b605b89e22807e47508d64a03f4c8978f46d714cc393f0
6
+ metadata.gz: 6cba4584a349b14efdc077ffcaed1b94f041e0389f5782ff1bfd664e87cbbde4e180d554580f5920b854e27a0d024d18660077bd7ca2f6b9ea509e07b5605e7d
7
+ data.tar.gz: 4e30b92e358666030f691ab91f019001b42fc3fdf34acfaa9fa00d93a33ef4a2fb61a8358bb5ce88ce05e402efde0ac34206a219db1995b3c67c87bd666b86bd
@@ -94,7 +94,7 @@ module GraphQL
94
94
  # @param enum_value [EnumValue] A value to add to this type's set of values
95
95
  def add_value(enum_value)
96
96
  if @values_by_name.key?(enum_value.name)
97
- raise "Enum value names must be unique. `#{enum_value.name}` already exists."
97
+ raise "Enum value names must be unique. Value `#{enum_value.name}` already exists on Enum `#{name}`."
98
98
  end
99
99
 
100
100
  @values_by_name[enum_value.name] = enum_value
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require "fileutils"
3
+ require "graphql/rake_task/validate"
4
+
3
5
  module GraphQL
4
6
  # A rake task for dumping a schema as IDL or JSON.
5
7
  #
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphQL
4
+ class RakeTask
5
+ extend Rake::DSL
6
+
7
+ desc "Get the checksum of a graphql-pro version and compare it to published versions on GitHub and graphql-ruby.org"
8
+ task "graphql:pro:validate", [:gem_version] do |t, args|
9
+ version = args[:gem_version]
10
+ check = "\e[32m✓\e[0m"
11
+ ex = "\e[31m✘\e[0m"
12
+ puts "Validating graphql-pro v#{version}"
13
+ puts " - Checking for graphql-pro credentials..."
14
+
15
+ creds = `bundle config gems.graphql.pro`[/[a-z0-9]{11}:[a-z0-9]{11}/]
16
+ if creds.nil?
17
+ puts " #{ex} failed, please set with `bundle config gems.graphql.pro $MY_CREDENTIALS`"
18
+ exit(1)
19
+ else
20
+ puts " #{check} found"
21
+ end
22
+
23
+ puts " - Fetching the gem..."
24
+ fetch_result = `gem fetch graphql-pro -v #{version} --source https://#{creds}@gems.graphql.pro`
25
+ if fetch_result.empty?
26
+ puts " #{ex} failed to fetch v#{version}"
27
+ exit(1)
28
+ else
29
+ puts " #{check} fetched"
30
+ end
31
+
32
+ puts " - Validating digest..."
33
+ require "digest/sha2"
34
+ gem_digest = Digest::SHA512.new.hexdigest(File.read("graphql-pro-#{version}.gem"))
35
+ require "net/http"
36
+ github_uri = URI("https://raw.githubusercontent.com/rmosolgo/graphql-ruby/master/guides/pro/checksums/graphql-pro-#{version}.txt")
37
+ # Remove final newline from .txt file
38
+ github_digest = Net::HTTP.get(github_uri).chomp
39
+
40
+ docs_uri = URI("https://raw.githubusercontent.com/rmosolgo/graphql-ruby/master/guides/pro/checksums/graphql-pro-#{version}.txt")
41
+ docs_digest = Net::HTTP.get(docs_uri).chomp
42
+
43
+ if docs_digest == gem_digest && github_digest == gem_digest
44
+ puts " #{check} validated from GitHub"
45
+ puts " #{check} validated from graphql-ruby.org"
46
+ else
47
+ puts " #{ex} SHA mismatch:"
48
+ puts " Downloaded: #{gem_digest}"
49
+ puts " GitHub: #{github_digest}"
50
+ puts " graphql-ruby.org: #{docs_digest}"
51
+ puts ""
52
+ puts " This download of graphql-pro is invalid, please open an issue:"
53
+ puts " https://github.com/rmosolgo/graphql-ruby/issues/new?title=graphql-pro%20digest%20mismatch%20(#{version})"
54
+ exit(1)
55
+ end
56
+
57
+ puts "\e[32m✔\e[0m graphql-pro #{version} validated successfully!"
58
+ end
59
+ end
60
+ end
@@ -100,7 +100,12 @@ module GraphQL
100
100
 
101
101
  # If a relation contains a `.group` clause, a `.count` will return a Hash.
102
102
  def relation_count(relation)
103
- count_or_hash = relation.count
103
+ count_or_hash = case relation
104
+ when ActiveRecord::Relation
105
+ relation.count(:all)
106
+ else # eg, Sequel::Dataset, don't mess up others
107
+ relation.count
108
+ end
104
109
  count_or_hash.is_a?(Integer) ? count_or_hash : count_or_hash.length
105
110
  end
106
111
 
@@ -12,7 +12,13 @@ module GraphQL
12
12
  }
13
13
 
14
14
  context.visitor[GraphQL::Language::Nodes::Argument] << ->(node, parent) {
15
- node_values = Array.wrap(node.value).select { |value| value.is_a? GraphQL::Language::Nodes::VariableIdentifier }
15
+ node_values = if node.value.is_a?(Array)
16
+ node.value
17
+ else
18
+ [node.value]
19
+ end
20
+ node_values = node_values.select { |value| value.is_a? GraphQL::Language::Nodes::VariableIdentifier }
21
+
16
22
  return if node_values.none?
17
23
 
18
24
  arguments = nil
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.6.5"
3
+ VERSION = "1.6.6"
4
4
  end
@@ -113,9 +113,13 @@ describe GraphQL::EnumType do
113
113
 
114
114
  describe "validates enum value name uniqueness" do
115
115
  it "raises an exception when adding a duplicate enum value name" do
116
- assert_raises "Enum value names must be unique. `COW` already exists." do
116
+ expected_message = "Enum value names must be unique. Value `COW` already exists on Enum `DairyAnimal`."
117
+
118
+ exception = assert_raises do
117
119
  enum.add_value(GraphQL::EnumType::EnumValue.define(name: "COW"))
118
120
  end
121
+
122
+ assert_equal(expected_message, exception.message)
119
123
  end
120
124
  end
121
125
  end
@@ -481,6 +481,14 @@ describe GraphQL::Relay::RelationConnection do
481
481
  end
482
482
 
483
483
  describe "for an ActiveRecord::Relation" do
484
+ describe "#has_next_page" do
485
+ it "handles joined, aliased relations" do
486
+ relation = StarWars::Base.select("id AS crazy_id")
487
+ connection = GraphQL::Relay::RelationConnection.new(relation, { first: 1 })
488
+ assert connection.has_next_page
489
+ end
490
+ end
491
+
484
492
  describe "#edge_nodes" do
485
493
  it "returns the nodes for the current page" do
486
494
  # Offset
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.5
4
+ version: 1.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-13 00:00:00.000000000 Z
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -440,6 +440,7 @@ files:
440
440
  - lib/graphql/query/variable_validation_error.rb
441
441
  - lib/graphql/query/variables.rb
442
442
  - lib/graphql/rake_task.rb
443
+ - lib/graphql/rake_task/validate.rb
443
444
  - lib/graphql/relay.rb
444
445
  - lib/graphql/relay/array_connection.rb
445
446
  - lib/graphql/relay/base_connection.rb