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 +4 -4
- data/README.md +13 -0
- data/lib/graphql/relay/base_connection.rb +9 -3
- data/lib/graphql/relay/relation_connection.rb +8 -1
- data/lib/graphql/relay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72df43a2a611dfb93bb640fa8796d5afc308355b
|
4
|
+
data.tar.gz: c9bd23e5f3afd777bf8e43d538b9f53a26556a3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
40
|
-
|
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
|
-
|
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
|
|
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.
|
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:
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|