strawberry icon indicating copy to clipboard operation
strawberry copied to clipboard

Quality of life improvements for GlobalIDs

Open patrick91 opened this issue 1 year ago • 3 comments

I think we should add the following APIs:

GlobalID.from_str("Node:1")
GlobalID("Node", 1) # support for numbers
GlobalID(...).as_string() # not sure about the name, but it's nicer than str(GlobalID(...))

I'd use these in tests 😊

patrick91 avatar Nov 11 '24 17:11 patrick91

while adding these APIs should GlobalID be renamed to ID too? (reference: #3551 )

(existing PR: #3180 )

aryaniyaps avatar Nov 12 '24 01:11 aryaniyaps

@aryaniyaps I think that is unrelated - you can have an ID scalar in your schema even though it is not globally unique. Conversely, an ID in your schema can be a globally unique global ID. This ticket is only intended to make life easier with a specific standard of global IDs (Base64 "Typename:id").

erikwrede avatar Nov 12 '24 08:11 erikwrede

@aryaniyaps I think that is unrelated - you can have an ID scalar in your schema even though it is not globally unique. Conversely, an ID in your schema can be a globally unique global ID. This ticket is only intended to make life easier with a specific standard of global IDs (Base64 "Typename:id").

I can see that its unrelated to this issue, but I feel that putting it off will further burden migrations from GlobalID to ID.. right now the schema generated by default doesnt play well with relay, and a workaround is needed to make things work.. so I thought it would be worth bringing up that issue as well..

aryaniyaps avatar Nov 12 '24 14:11 aryaniyaps