graphql-relay 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fc4e49e9a152eb3d06a00ea6dc479ca20ad3b85
4
- data.tar.gz: 3babba6d3a517b0d0a0da7afced0e005dcfa75f1
3
+ metadata.gz: 6284053a13755747eea7b324a8c95c6acac7a2ce
4
+ data.tar.gz: 12fd8d7abd63b48100a90212fc2386762129fdd9
5
5
  SHA512:
6
- metadata.gz: f84efd30fb1fe8cdd776656e5d8e3bba8ec2ff2cecdaf403fa2652dcc1d4bfced113b6535d89cdc51bf6f2033fc3702f284fc8c758f5329affaefedb4bb7dd3f
7
- data.tar.gz: 9331b1c45d8401c462192fd5c431736dbd4924f812223781827dc145a4b7c2eb89e127431156ee8667e14aaae64f7d6466ec1cbc3f5e9a414f693efbbedde098
6
+ metadata.gz: 0df6bf1e5c4f2ac0d10e8f1328159fab1c802e969c26c3c274c3e1075b525aca788b21f24cb8cd1a0ae636838143d00d9c4e83441b94735431ae08c00c288165
7
+ data.tar.gz: 4a9e932f728d71c8763c072b4d6e419b1d37d5da5607fe68deb7bf87a4c1850ae19ba1328d2a0483accedfcea35ab4e4820d8d76202891363e85ed46cbae3121
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # graphql-relay
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/graphql-relay.svg)](http://badge.fury.io/rb/graphql-relay)
4
+ [![Code Climate](https://codeclimate.com/github/rmosolgo/graphql-relay-ruby/badges/gpa.svg)](https://codeclimate.com/github/rmosolgo/graphql-relay-ruby)
5
+ [![Test Coverage](https://codeclimate.com/github/rmosolgo/graphql-relay-ruby/badges/coverage.svg)](https://codeclimate.com/github/rmosolgo/graphql-relay-ruby/coverage)
6
+
3
7
  Helpers for using [`graphql`](https://github.com/rmosolgo/graphql-ruby) with Relay.
4
8
 
5
9
  ## Installation
@@ -112,7 +112,7 @@ module GraphQL
112
112
  end
113
113
 
114
114
  def clientMutationId
115
- arguments[:clientMutationId]
115
+ arguments[:input][:clientMutationId]
116
116
  end
117
117
 
118
118
  def method_missing(name, *args, &block)
@@ -35,16 +35,16 @@ module GraphQL
35
35
 
36
36
  if after
37
37
  _o, order_value = slice_from_cursor(after)
38
- sort_query = order_direction == :asc ? "? > ?" : "? < ?"
39
- puts sort_query, order_name, order_value
40
- items = items.where(sort_query, order_name, order_value)
38
+ direction_marker = order_direction == :asc ? ">" : "<"
39
+ where_condition = create_order_condition(order_name, order_value, direction_marker)
40
+ items = items.where(where_condition)
41
41
  end
42
42
 
43
43
  if before
44
44
  _o, order_value = slice_from_cursor(before)
45
- sort_query = order_direction == :asc ? "? < ?" : "? > ?"
46
- p [sort_query, order_name, order_value]
47
- items = items.where(sort_query, order_name, order_value)
45
+ direction_marker = order_direction == :asc ? "<" : ">"
46
+ where_condition = create_order_condition(order_name, order_value, direction_marker)
47
+ items = items.where(where_condition)
48
48
  end
49
49
 
50
50
  items
@@ -65,6 +65,11 @@ module GraphQL
65
65
  def order_direction
66
66
  @order_direction ||= order.start_with?("-") ? :desc : :asc
67
67
  end
68
+
69
+ def create_order_condition(column, value, direction_marker)
70
+ name = ActiveRecord::Base.connection.quote_column_name(column)
71
+ ["#{name} #{direction_marker} ?", value]
72
+ end
68
73
  end
69
74
  end
70
75
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Relay
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -30,5 +30,9 @@ describe GraphQL::Relay::Mutation do
30
30
  "faction" => {"name" => STAR_WARS_DATA["Faction"]["1"].name }
31
31
  }
32
32
  }}
33
+ assert_equal(expected, result)
34
+ # Cleanup:
35
+ STAR_WARS_DATA["Ship"].delete("9")
36
+ STAR_WARS_DATA["Faction"]["1"]["ships"].delete("9")
33
37
  end
34
38
  end
data/spec/spec_helper.rb CHANGED
@@ -17,5 +17,5 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
17
 
18
18
 
19
19
  def query(string, variables={})
20
- GraphQL::Query.new(StarWarsSchema, string, variables: variables).result
20
+ GraphQL::Query.new(StarWarsSchema, string, variables: variables, debug: true).result
21
21
  end
@@ -26,7 +26,7 @@ empire = OpenStruct.new({
26
26
  })
27
27
 
28
28
  ## Set up "Bases" in ActiveRecord
29
- ActiveRecord::Base.logger = Logger.new(STDOUT)
29
+ # ActiveRecord::Base.logger = Logger.new(STDOUT)
30
30
  ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
31
31
 
32
32
  ActiveRecord::Schema.define do
@@ -35,7 +35,7 @@ BaseType = GraphQL::ObjectType.define do
35
35
  field :planet, types.String
36
36
  end
37
37
 
38
- # Define a connection which will wrap an array:
38
+ # Define a connection which will wrap an ActiveRecord::Relation:
39
39
  BaseConnection = GraphQL::Relay::RelationConnection.create_type(BaseType)
40
40
 
41
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-relay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
@@ -178,7 +178,8 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- description: Connections, UUID, etc?
181
+ description: Define global ids, connections and mutations to use GraphQL and Relay
182
+ with a Ruby server.
182
183
  email:
183
184
  - rdmosolgo@gmail.com
184
185
  executables: []