-
-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Relay) Output ID instead of GlobalID in GraphQL schema #3551
Comments
Here is a temporary solution for anyone who has the same issue, until this has been resolved: import strawberry
from strawberry.relay import GlobalID
# temporary hack until strawberry fixes relay ID scalar generation
ID = strawberry.scalar(
strawberry.ID,
serialize=lambda value: str(value),
parse_value=lambda value: GlobalID.from_id(value=value),
)
schema = Schema(
query=query,
mutation=mutation,
scalar_overrides={GlobalID: ID},
) |
@aryaniyaps your temporary solution doesn't seem to work for me. I'm getting this: What version of strawberry are you using? |
I think the issue is, after creating a scalar like this; ID = strawberry.scalar(
strawberry.ID,
serialize=lambda value: str(value),
parse_value=lambda value: GlobalID.from_id(value=value),
) You are using I'm on version 0.235.0 btw |
This was helpful, thank you |
Request to output the
ID
scalar instead ofGlobalID
, while generating the GraphQL schemaMy understanding is that
GlobalID
was meant to be an internal helper that resolves nodes, but ended up being a custom scalar.Feature Request Type
Description
Currently, while using the relay integration, and working with node types, like the example code below:
We get a schema output like this:
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 notGlobalID
.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 notGlobalID
.An example relay compiler error is shown below:
Output GraphQL schema (After requested change)
It would be nice if we could change the
GlobalID
scalar being generated toID
Upvote & Fund
The text was updated successfully, but these errors were encountered: