graphql-activerecord 0.12.2 → 0.12.3

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: 6c83f3a8016448bb97d1e15a2e4c3958ab631725
4
- data.tar.gz: 0f4683f753d5a45a3b9c5d473cb3c2546dd833e7
3
+ metadata.gz: c10e3d4bc80c946d07858e467a8c0b1dfaf5dce1
4
+ data.tar.gz: 24dc06e7b2fa34ccadc5c6ad0367cb276358e8d2
5
5
  SHA512:
6
- metadata.gz: f29777ba30b72b285a24fff31fc6e8354e7f85cef43d2355dc88b4e405e45284e044b1acc0a9cad0027e734b6eb93d00baed3129fa246649372656684549fd4e
7
- data.tar.gz: 8add41735a53eb7ff17bb291a0f0c6f12a6e70dc2093515f2c8cf099fcdbb4702fcaaf2b081a211c98c54431fea87ba0123dceb22ce5114e468883514150aa05
6
+ metadata.gz: fef3385be87b2d02ff298382d934d37f6dc82741947ac1cf9a8532ccdc8df8eaccff2f8ccc808e065a2f8a2b31faae66265ebf794daee6c40bdcedcc3de98934
7
+ data.tar.gz: 5b06f43ebcb3d7d014937ec764faec65e344fba94b90c3ba9782bb94f27e29a5944e06963aa06f64c67c24b063cf65a8a152ca84d265e3f28684d239c523ab5b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ # 0.12.3
4
+ - If possible, try to get the description for a field from the column's comment in the database. (#40)
5
+ - Automatically generated union types (for polymorphic associations) used `demodulize` on the class name. If your model is `Name::Spaced`, this fixes a bug where it generates an invalid name. (#42)
6
+
3
7
  # 0.12.2
4
8
  In mutators, the gem now supports updating nested models, where the `find_by` option specifies an ID field. This works similarly
5
9
  to input fields that accept ID values: it expects a global ID value to be provided, and uses your configured `model_from_id` proc
@@ -39,7 +43,7 @@ There are a few breaking changes:
39
43
  to bring it more in line with common practice. You can get the old behavior by adding this to an initializer:
40
44
 
41
45
  ```ruby
42
- GraphQL::Models.model_to_graphql_type -> (model_class) { "#{model_class.name}Graph".safe_constantize }
46
+ GraphQL::Models.model_to_graphql_type = -> (model_class) { "#{model_class.name}Graph".safe_constantize }
43
47
  ```
44
48
 
45
49
  - Fixed a bug with the `has_many_connection` helper, which deserves some explanation. This helper constructs a
data/README.md CHANGED
@@ -132,7 +132,7 @@ GraphQL::Models.authorize = -> (context, action, model) {
132
132
 
133
133
  # The gem assumes that if your model is called `MyModel`, the corresponding type is `MyModelType`.
134
134
  # You can override that convention. Return `nil` if the model doesn't have a GraphQL type:
135
- GraphQL::Models.model_to_graphql_type -> (model_class) { "#{model_class.name}Graph".safe_constantize }
135
+ GraphQL::Models.model_to_graphql_type = -> (model_class) { "#{model_class.name}Graph".safe_constantize }
136
136
  ```
137
137
 
138
138
  Finally, you need to set a few options on your schema:
@@ -386,6 +386,9 @@ them. It will destroy extra models, or create missing models.
386
386
  - Retrieving field metadata (for building an authorization middleware)
387
387
  - Validation error exceptions
388
388
 
389
+ ## Getting Help
390
+
391
+ The best way to get ahold of me (@theorygeek) is in the #ruby channel on the [GraphQL Slack](https://graphql-slack.herokuapp.com/). Or feel free to open a GitHub issue (or PR), although to my shame, I'm not very good at responding to those (sorry, I'm trying to get better 😞).
389
392
 
390
393
  ## Development
391
394
 
@@ -41,6 +41,12 @@ module GraphQL
41
41
  def attr(attribute, name: attribute.to_s.camelize(:lower), nullable: nil, description: nil, deprecation_reason: nil, &block)
42
42
  name = name.to_sym unless name.is_a?(Symbol)
43
43
 
44
+ # Get the description from the column, if it's not provided. Doesn't work in Rails 4 :(
45
+ unless description
46
+ column = @model_type.columns_hash[attribute.to_s]
47
+ description = column.comment if column&.respond_to?(:comment)
48
+ end
49
+
44
50
  options = {
45
51
  name: name,
46
52
  nullable: nullable,
@@ -41,7 +41,7 @@ module GraphQL
41
41
  graph_types = valid_types.map { |t| GraphQL::Models.get_graphql_type(t) }.compact
42
42
 
43
43
  GraphQL::UnionType.define do
44
- name "#{model_type.name}#{reflection.foreign_type.classify}"
44
+ name "#{model_type.name.demodulize}#{reflection.foreign_type.classify}"
45
45
  description "Objects that can be used as #{reflection.foreign_type.titleize.downcase} on #{model_type.name.titleize.downcase}"
46
46
  possible_types graph_types
47
47
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
3
  module Models
4
- VERSION = "0.12.2"
4
+ VERSION = "0.12.3"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Foster
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport