graphql-relay 0.6.1 → 0.6.2

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: ea4c2cc57f963c64ecb34d90f53e32e943faf1bc
4
- data.tar.gz: a520db57682116bd3f93d5db075d41f88320ca33
3
+ metadata.gz: 72df43a2a611dfb93bb640fa8796d5afc308355b
4
+ data.tar.gz: c9bd23e5f3afd777bf8e43d538b9f53a26556a3c
5
5
  SHA512:
6
- metadata.gz: 68bfb22e922e5fd87d65c7a42731c559fe02faac3c9c05acfb3f065c6d3325ae60bd8bab133677a2188b03caeadf7069c17ddcc1d0ae2ad774bd025b97e981fc
7
- data.tar.gz: 34475ee06278d2f5b814d874db45ec0150631811a98e50edddee7401c436f9b6e873936e2f75188779cdd45dfc8a43a6da798c02261b0dbbf270cbb21ea371a2
6
+ metadata.gz: c276a95e9777af270a4c0affa60904cb3312c1c1a8f82031c46ffb1268bb7509ddf80275992719cb735e3f5e6de96274b9848c0bc3235c8063d4b702bcfc4459
7
+ data.tar.gz: eafed64a5566fa095032681a62e22527255700abf4e225abd89da7d0c5d379d43fd4641746b8afd8e1840c40ea6af23e9e2a01df16c68f4322682b0f183a123e
data/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  Helpers for using [`graphql`](https://github.com/rmosolgo/graphql-ruby) with Relay.
9
9
 
10
+ [API Documentation](http://www.rubydoc.info/github/rmosolgo/graphql-relay-ruby)
10
11
  ## Installation
11
12
 
12
13
  ```ruby
@@ -294,6 +295,18 @@ The resolve proc:
294
295
  - Takes `ctx`, which is the query context you passed with the `context:` keyword
295
296
  - Must return a hash with keys matching your defined `return_field`s
296
297
 
298
+ ## Getting Started Tutorials
299
+
300
+ #### Series: Building a blog in GraphQL and Relay on Rails
301
+ 1. **Introduction:** https://medium.com/@gauravtiwari/graphql-and-relay-on-rails-getting-started-955a49d251de
302
+ 2. **Part1:** https://medium.com/@gauravtiwari/graphql-and-relay-on-rails-creating-types-and-schema-b3f9b232ccfc
303
+ 3. **Part2:**
304
+ https://medium.com/@gauravtiwari/graphql-and-relay-on-rails-first-relay-powered-react-component-cb3f9ee95eca
305
+
306
+ #### Tutorials
307
+ 1. https://medium.com/@khor/relay-facebook-on-rails-8b4af2057152
308
+ 2. http://mgiroux.me/2015/getting-started-with-rails-graphql-relay/
309
+ 3. http://mgiroux.me/2015/uploading-files-using-relay-with-rails/
297
310
 
298
311
  ## Todo
299
312
 
@@ -36,8 +36,14 @@ module GraphQL
36
36
  # @param [Object] A collection of items (eg, Array, AR::Relation)
37
37
  # @return [subclass of BaseConnection] a connection Class for wrapping `items`
38
38
  def self.connection_for_items(items)
39
- implementation = CONNECTION_IMPLEMENTATIONS.find do |items_class, connection_class|
40
- items.is_a?(items_class)
39
+ # We check class membership by comparing class names rather than
40
+ # identity to prevent this from being broken by Rails autoloading.
41
+ # Changes to the source file for ItemsClass in Rails apps cause it to be
42
+ # reloaded as a new object, so if we were to use `is_a?` here, it would
43
+ # no longer match any registered custom connection types.
44
+ ancestor_names = items.class.ancestors.map(&:name)
45
+ implementation = CONNECTION_IMPLEMENTATIONS.find do |items_class_name, connection_class|
46
+ ancestor_names.include? items_class_name
41
47
  end
42
48
  if implementation.nil?
43
49
  raise("No connection implementation to wrap #{items.class} (#{items})")
@@ -51,7 +57,7 @@ module GraphQL
51
57
  # @param [Class] A class representing a collection (eg, Array, AR::Relation)
52
58
  # @param [Class] A class implementing Connection methods
53
59
  def self.register_connection_implementation(items_class, connection_class)
54
- CONNECTION_IMPLEMENTATIONS[items_class] = connection_class
60
+ CONNECTION_IMPLEMENTATIONS[items_class.name] = connection_class
55
61
  end
56
62
 
57
63
  attr_reader :object, :arguments
@@ -71,10 +71,17 @@ module GraphQL
71
71
  @table_name ||= object.table.table_name
72
72
  end
73
73
 
74
+ # When creating the where constraint, cast the value to correct column data type so
75
+ # active record can send it in correct format to db
74
76
  def create_order_condition(table, column, value, direction_marker)
75
77
  table_name = ActiveRecord::Base.connection.quote_table_name(table)
76
78
  name = ActiveRecord::Base.connection.quote_column_name(column)
77
- ["#{table_name}.#{name} #{direction_marker} ?", value]
79
+ if (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR >= 2) || ActiveRecord::VERSION::MAJOR > 4
80
+ casted_value = object.table.engine.columns_hash[column].cast_type.type_cast_from_user(value)
81
+ else
82
+ casted_value = object.table.engine.columns_hash[column].type_cast(value)
83
+ end
84
+ ["#{table_name}.#{name} #{direction_marker} ?", casted_value]
78
85
  end
79
86
  end
80
87
 
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Relay
3
- VERSION = '0.6.1'
3
+ VERSION = '0.6.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-relay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql