Closed mxstbr closed 9 months ago
That should just require you to override the scalar though in your codegen/tada init
export const graphql = initGraphQLTada<{
introspection: typeof introspection
scalars: {
ID: string
}
}>()
That would work, but override it for all types, right?
I have other types that do have numeric IDs.
How is that possible, the base64 identifier is always a string, no? So by extension when using ID!
and hence encoding type:id
to base64 it should always be a string. I guess the replace
in general isn't the best idea here as this will be a base64 encoded global id which won't be the value you are looking for. ID
in GraphQL isn't meant to be manipulated, what you can however do is send down an _id
that exposes id
if you want that but generally ID
is meant to be opaque.
Oh right, I forgot that we make IDs globally unique while I was reworking an existing app that does story.id.replace
—but of course, story.id
used to be the non-opaque ID.
Summary
I have a type called
Story
that has an ID that is always a string. However, Fuse auto-generatesid: ID!
, which (in TypeScript) converts tostring | number
. That, in turn, means that I'm getting errors from typechecking when I dostory.id.replace(…)
because.replace
doesn't exist onnumber
—but my ID will always be a string!Proposed Solution
Allow overriding the
id
field manually: