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 +4 -4
 - data/.travis.yml +6 -0
 - data/CHANGELOG.md +5 -1
 - data/Gemfile +2 -3
 - data/graphql-1.7.gemfile +8 -0
 - data/graphql-1.8.gemfile +8 -0
 - data/lib/graphql/guard.rb +12 -4
 - data/lib/graphql/guard/testing.rb +14 -0
 - data/lib/graphql/guard/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5b48e82ed231f10a52a828e2ff8d37ff7852da0d4292ec2b9679b54b2fd31543
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b804211c38f522e74fe048040d6e86e49f396a18311e0ebb1d8b1d78f3c34c4a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ce83f0ce8ad73fe4bc31b50efef3b862c1e92fc4b53619932efd59070a49f09cff02088de27ab24327a03ff8eed07e58485223835e03037d91d0eca62e3e61f7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6c2f05231bfba7feaa27adae6e46ee7651d250c38477347773bce38f2699cd7feef35b1e8e5d0324a61a3e62702b2b1a99eb4bf8274afbc9e2c0ecd0f23e98d8
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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
    
    
    
        data/graphql-1.7.gemfile
    ADDED
    
    
    
        data/graphql-1.8.gemfile
    ADDED
    
    
    
        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
         
     | 
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 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
         
     |