strawberry.relay.GlobalID
Global ID for relay types.
Different from strawberry.ID
, this ID wraps the original object ID in a string
that contains both its GraphQL type name and the ID itself, and encodes it
to a base64_ string.
This object contains helpers to work with that, including method to retrieve the python object type or even the encoded node itself.
Attributes: type_name: The type name part of the id node_id: The node id part of the id
.. _base64: https://en.wikipedia.org/wiki/Base64
Constructor:
Signature:
Parameters:
-
type_name:
- Type
-
str
-
node_id:
- Type
-
str
Methods:
-
from_id
Create a new GlobalID from parsing the given value.
Returns:
An instance of GLobalID
Signature:
Parameters:
-
value:
The value to be parsed, as a base64 string in the “TypeName:NodeID” format
- Type
-
str | ID
-
-
resolve_node
Resolve the type name and node id info to the node itself.
Tip: When you know the expected type, calling
ensure_type
should help not only to enforce it, but also help with typing since it will know that, if this function returns successfully, the retval should be of that type and notNode
.Returns:
The resolved node
Signature:
Parameters:
-
info:
The strawberry execution info resolve the type name from
-
required:
If the value is required to exist. Note that asking to ensure the type automatically makes required true.
- Default
-
False
-
ensure_type:
Optionally check if the returned node is really an instance of this type.
- Default
-
None
-
-
resolve_type
Resolve the internal type name to its type itself.
Returns:
The resolved GraphQL type for the execution info
Signature:
Parameters:
-
info:
The strawberry execution info resolve the type name from
- Type
-
Info
-
-
resolve_node_sync
Resolve the type name and node id info to the node itself.
Tip: When you know the expected type, calling
ensure_type
should help not only to enforce it, but also help with typing since it will know that, if this function returns successfully, the retval should be of that type and notNode
.Returns:
The resolved node
Signature:
Parameters:
-
info:
The strawberry execution info resolve the type name from
-
required:
If the value is required to exist. Note that asking to ensure the type automatically makes required true.
- Default
-
False
-
ensure_type:
Optionally check if the returned node is really an instance of this type.
- Default
-
None
-
Attributes:
-
type_name:
- Type
-
str
-
node_id:
- Type
-
str