Skip to content

ID typescript type #105

Answered by hayes
jamiehodge asked this question in Q&A
Jul 2, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I generally re-define it as string like you mentioned, but the default is the way it is because the graphql server implementations (and graphql js itself) allow numbers to be passed through for ids. I like ids always being strings, but its not something that is enforced by default, so if you want it to be type-safe you need to find a way convert your inputs. I've done this a couple different ways, but I don't have a method I feel comfortable recommending. It can be done with a custom girapqhl plugin that wraps resolvers (the way globalId input parsing works in the relay plugin is the closest example I can think of). It can be handled by a custom plugin for your server (apollo and graphql …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GauBen
Comment options

Answer selected by hayes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #95 on July 20, 2021 17:48.