GreenFairy.GlobalId.Base64 (GreenFairy v0.3.0)
View SourceDefault Base64 implementation of the GlobalId behaviour.
This follows the Relay Object Identification specification where
global IDs are Base64-encoded strings in the format TypeName:localId.
Examples
# Encoding
Base64.encode("User", 123)
#=> "VXNlcjoxMjM="
Base64.encode(:user_profile, 42)
#=> "VXNlclByb2ZpbGU6NDI="
# Decoding
Base64.decode("VXNlcjoxMjM=")
#=> {:ok, {"User", "123"}}
Summary
Functions
Decodes a Base64 global ID into its type name and local ID.
Encodes a type name and local ID into a Base64 global ID.
Functions
Decodes a Base64 global ID into its type name and local ID.
Returns {:ok, {type_name, local_id}} on success, or {:error, reason} on failure.
Encodes a type name and local ID into a Base64 global ID.
The type name can be an atom or string. Atoms are converted to
PascalCase (e.g., :user_profile becomes "UserProfile").