Request to output the ID
scalar instead of GlobalID
, while generating the GraphQL schema
My understanding is that GlobalID
was meant to be an internal helper that resolves nodes, but ended up being a custom scalar.
Currently, while using the relay integration, and working with node types, like the example code below:
import strawberry
from strawberry import relay
@strawberry.type
class Fruit(relay.Node):
code: relay.NodeID[int]
name: str
weight: float
@classmethod
def resolve_nodes(
cls,
*,
info: strawberry.Info,
node_ids: Iterable[str],
required: bool = False,
):
return [
all_fruits[int(nid)] if required else all_fruits.get(nid)
for nid in node_ids
]
We get a schema output like this:
scalar GlobalID
interface Node {
id: GlobalID!
}
type Fruit implements Node {
id: GlobalID!
name: String!
weight: Float!
}
But in the relay specification, which the GlobalID scalar is based on:
https://relay.dev/graphql/objectidentification.htm
calls this scalar by the name ID
, and not GlobalID
.
I think that there is no mention of a custom scalar to be returned for object identification.
This leads to a lot of issues while working with client libraries such as relay, where directives expect the return type to be the scalar type of ID
, and not GlobalID
.
An example relay compiler error is shown below:
> [email protected] relay
> relay-compiler
[INFO] [default] compiling...
[ERROR] Error: βοΈ Invalid use of @deleteEdge on field 'deletedTodoId'. Expected field type 'ID', got 'GlobalID'.
client/src/components/home-page/Todo.tsx:20:21
19 β deleteTodo(todoId: $todoId) {
20 β deletedTodoId @deleteEdge(connections: $connections)
β ^^^^^^^^^^^
21 β }
[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
- Validation errors: 1 error(s) encountered above.
interface Node {
id: ID!
}
type Fruit implements Node {
id: ID!
name: String!
weight: Float!
}
It would be nice if we could change the GlobalID
scalar being generated to ID
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too