Module: GraphQL::Schema::UniqueWithinType
- Defined in:
- lib/graphql/schema/unique_within_type.rb
Class Attribute Summary collapse
- 
  
    
      .default_id_separator  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute default_id_separator. 
Class Method Summary collapse
- 
  
    
      .decode(node_id, separator: self.default_id_separator)  ⇒ Array<(String, String)> 
    
    
  
  
  
  
  
  
  
  
  
    The type name & value passed to UniqueWithinType.encode. 
- 
  
    
      .encode(type_name, object_value, separator: self.default_id_separator)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    A unique, opaque ID generated as a function of the two inputs. 
Class Attribute Details
.default_id_separator ⇒ Object
Returns the value of attribute default_id_separator.
| 8 9 10 | # File 'lib/graphql/schema/unique_within_type.rb', line 8 def default_id_separator @default_id_separator end | 
Class Method Details
.decode(node_id, separator: self.default_id_separator) ⇒ Array<(String, String)>
Returns The type name & value passed to encode.
| 29 30 31 | # File 'lib/graphql/schema/unique_within_type.rb', line 29 def decode(node_id, separator: self.default_id_separator) GraphQL::Schema::Base64Encoder.decode(node_id).split(separator, 2) end | 
.encode(type_name, object_value, separator: self.default_id_separator) ⇒ String
Returns a unique, opaque ID generated as a function of the two inputs.
| 17 18 19 20 21 22 23 24 25 | # File 'lib/graphql/schema/unique_within_type.rb', line 17 def encode(type_name, object_value, separator: self.default_id_separator) object_value_str = object_value.to_s if type_name.include?(separator) raise "encode(#{type_name}, #{object_value_str}) contains reserved characters `#{separator}` in the type name" end Base64.strict_encode64([type_name, object_value_str].join(separator)) end |