lvarayut / relay-fullstack

:point_up::running: Modern Relay Starter Kit - Integrated with Relay, GraphQL, Express, ES6/ES7, JSX, Webpack, Babel, Material Design Lite, and PostCSS
https://lvarayut.github.io/relay-fullstack/
MIT License
985 stars 126 forks source link

id should be strings not int ? #91

Closed apage224 closed 7 years ago

apage224 commented 7 years ago

I believe I found an issue with the way IDs are being used in the example. database.js uses int type for IDs rather than string type. In schema.js the queryType uses getUser(1) using 1 for the resolver of viewer. However, in nodeDefinitions the first method uses fromGlobalId which I believe returns an id as a string. Thus when type is 'User' the getUser(id) will have an id of '1' which causes the function to incorrectly return null. Simple fix would be to use abstract equality (==) vs strict equality (===) in getUser() and getFeature() OR use string IDs.

I noticed this when I had a need to perform a force query (w/ forcefetch={true} on viewer and got back null.

On a side note, I notice your still using react-mdl which is deprecated. I would highly recommend material-ui.

Neitsch commented 7 years ago

Thanks for spotting that! Yeah, at some point I changed IDs to int, but must have missed that instance. Will address this (or you can PR). Concerning react-mdl, a PR is also welcome :)

lvarayut commented 7 years ago

@apage2, the issue's fixed in https://github.com/lvarayut/relay-fullstack/pull/93. Regarding the react-mdl, we plan to remove it entirely and use just a vanilla css 😄