-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
As discussed in #232, __id
doesn't really make sense if it actually returns the global ID, since double-underscore fields are usually used for type information. But what if it did return type information (the name of the global ID field), and that field was defined using a directive?
The original idea comes from @leebyron
and @calebmer
here.
Example
Specifying a global identifier field
type Person {
id: ID! # Entity/local ID.
myGlobalId: ID! @globalIdField # This could instead be added to a `Node` interface, that `Person` implements.
name: String
}
Selection
{
person {
__globalIdField
myGlobalId
id
name
}
}
{
"data": {
"person": {
"__globalIdField": "myGlobalId",
"myGlobalId": "person-123",
"id": "123",
"name": "Jane Doe",
}
}
}
Introspection
{
__type(name: "Person") {
name
globalIdField
}
}
{
"data": {
"__type": {
"name": "Person",
"globalIdField": "myGlobalId"
}
}
}
Something like @idField
could perhaps also be added for non-global IDs. Built-in directives may need some form of namespacing – not sure if something like @__idField
would look good, but there may be other alternatives like @@idField
).
Could something like this work?
ErikJson
Metadata
Metadata
Assignees
Labels
No labels