Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

consider aliasing ID type to string only #12

Closed
sorenbs opened this issue Dec 29, 2017 · 2 comments
Closed

consider aliasing ID type to string only #12

sorenbs opened this issue Dec 29, 2017 · 2 comments

Comments

@sorenbs
Copy link

sorenbs commented Dec 29, 2017

Currently the ID type alias to string | number:

/*
The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.
*/
export type ID = string | number

This makes sense, but has the unfortunate consequence of making it more difficult to pass the id around internally:

image

I'm not sure this should change, but wanted to bring it up

@kbrandwijk
Copy link
Contributor

I think the same solution could be applied as for #10. Splitting the ID type, and having an InputId and OutputID type, with string | number and string respectively.

kbrandwijk added a commit that referenced this issue Dec 29, 2017
GraphQL ID types can be string or number, but are always returned as string. Typing the output type
as string makes it easier to use the return values.

Closes #12
@sorenbs
Copy link
Author

sorenbs commented Jan 1, 2018

I like this approach 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants