graphql-guard 1.1.0 → 1.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
  SHA256:
3
- metadata.gz: 1356ec0ce6198540fffd1ca245c4b138792bc81ff776094a8b1ac6e12e2940d6
4
- data.tar.gz: 1282de4a1c06f4c32bba870d8076fc94a276bf39cb2cb56e0cbd5f880aa73ff9
3
+ metadata.gz: 5b48e82ed231f10a52a828e2ff8d37ff7852da0d4292ec2b9679b54b2fd31543
4
+ data.tar.gz: b804211c38f522e74fe048040d6e86e49f396a18311e0ebb1d8b1d78f3c34c4a
5
5
  SHA512:
6
- metadata.gz: d6c831b4be4415ed4b10f575bab5b7b2d6888965972bd9bdb7dcc1ec4477f46542e66d8b8d1566b27a3e4f044e66bc76a018920567710f4f7f723a8a6e4b02c7
7
- data.tar.gz: ac3d9a36703f5f206ba40c776d2d0476a287ab99534b2e1fd27e97459ed7af3549d6cc4ef956b7f8a878f26f9b879cd8f42f0746d1c2e8d3b23f246b54f76f76
6
+ metadata.gz: ce83f0ce8ad73fe4bc31b50efef3b862c1e92fc4b53619932efd59070a49f09cff02088de27ab24327a03ff8eed07e58485223835e03037d91d0eca62e3e61f7
7
+ data.tar.gz: 6c2f05231bfba7feaa27adae6e46ee7651d250c38477347773bce38f2699cd7feef35b1e8e5d0324a61a3e62702b2b1a99eb4bf8274afbc9e2c0ecd0f23e98d8
data/.travis.yml CHANGED
@@ -5,3 +5,9 @@ rvm:
5
5
  env:
6
6
  - CI=true
7
7
  before_install: gem install bundler -v 1.15.2
8
+ matrix:
9
+ include:
10
+ - gemfile: graphql-1.7.gemfile
11
+ env: GRAPHQL_RUBY_VERSION=1_7
12
+ - gemfile: graphql-1.8.gemfile
13
+ env: GRAPHQL_RUBY_VERSION=1_8
data/CHANGELOG.md CHANGED
@@ -8,10 +8,14 @@ one of the following labels: `Added`, `Changed`, `Deprecated`,
8
8
  to manage the versions of this gem so
9
9
  that you can set version constraints properly.
10
10
 
11
- #### [Unreleased](https://github.com/exAspArk/graphql-guard/compare/v1.1.0...HEAD)
11
+ #### [Unreleased](https://github.com/exAspArk/graphql-guard/compare/v1.2.0...HEAD)
12
12
 
13
13
  * WIP
14
14
 
15
+ #### [v1.2.0](https://github.com/exAspArk/graphql-guard/compare/v1.1.0...v1.2.0) – 2018-06-29
16
+
17
+ * `Added`: support for `graphql` gem version 1.8. [#17](https://github.com/exAspArk/graphql-guard/pull/17)
18
+
15
19
  #### [v1.1.0](https://github.com/exAspArk/graphql-guard/compare/v1.0.0...v1.1.0) – 2018-05-09
16
20
 
17
21
  * `Added`: support to `mask` fields depending on the context.
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
3
  gem "pry"
6
- gem 'coveralls', require: false
4
+
5
+ gem "graphql", "~> 1.8.4"
7
6
 
8
7
  # Specify your gem's dependencies in graphql-guard.gemspec
9
8
  gemspec
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "pry"
4
+ gem 'coveralls'
5
+
6
+ gem "graphql", "~> 1.7.14"
7
+
8
+ gemspec
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "pry"
4
+ gem 'coveralls'
5
+
6
+ gem "graphql", "~> 1.8.4"
7
+
8
+ gemspec
data/lib/graphql/guard.rb CHANGED
@@ -3,10 +3,6 @@
3
3
  require "graphql"
4
4
  require "graphql/guard/version"
5
5
 
6
- GraphQL::ObjectType.accepts_definitions(guard: GraphQL::Define.assign_metadata_key(:guard))
7
- GraphQL::Field.accepts_definitions(guard: GraphQL::Define.assign_metadata_key(:guard))
8
- GraphQL::Field.accepts_definitions(mask: GraphQL::Define.assign_metadata_key(:mask))
9
-
10
6
  module GraphQL
11
7
  class Guard
12
8
  ANY_FIELD_NAME = :'*'
@@ -72,3 +68,15 @@ module GraphQL
72
68
  end
73
69
  end
74
70
  end
71
+
72
+ if GraphQL::ObjectType.respond_to?(:accepts_definitions) # GraphQL-Ruby version < 1.8
73
+ GraphQL::ObjectType.accepts_definitions(guard: GraphQL::Define.assign_metadata_key(:guard))
74
+ GraphQL::Field.accepts_definitions(guard: GraphQL::Define.assign_metadata_key(:guard))
75
+ GraphQL::Field.accepts_definitions(mask: GraphQL::Define.assign_metadata_key(:mask))
76
+ end
77
+
78
+ if GraphQL::Schema::Object.respond_to?(:accepts_definition) # GraphQL-Ruby version >= 1.8
79
+ GraphQL::Schema::Object.accepts_definition(:guard)
80
+ GraphQL::Schema::Field.accepts_definition(:guard)
81
+ GraphQL::Schema::Field.accepts_definition(:mask)
82
+ end
@@ -33,4 +33,18 @@ module GraphQL
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ class Schema
38
+ class Object
39
+ def self.field_with_guard(field_name, policy_object = nil)
40
+ field = fields[field_name]
41
+ return unless field
42
+
43
+ field.to_graphql.clone.tap do |f|
44
+ f.__policy_object = policy_object
45
+ f.__guard_type = self.to_graphql
46
+ end
47
+ end
48
+ end
49
+ end
36
50
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  class Guard
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - exAspArk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-09 00:00:00.000000000 Z
11
+ date: 2018-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -91,6 +91,8 @@ files:
91
91
  - Rakefile
92
92
  - bin/console
93
93
  - bin/setup
94
+ - graphql-1.7.gemfile
95
+ - graphql-1.8.gemfile
94
96
  - graphql-guard.gemspec
95
97
  - lib/graphql/guard.rb
96
98
  - lib/graphql/guard/testing.rb