StellateHQ / fuse

Fuse: The fastest way to build and query great APIs with TypeScript
https://fusedata.dev
MIT License
550 stars 13 forks source link

Bug: node always have `id` even if `key` is set to something else #122

Closed mxstbr closed 9 months ago

mxstbr commented 9 months ago

Description

CleanShot 2024-01-16 at 12 24 16@2x

My User type has a username key. The underlying data does not have an id. Yet, the generated GraphQL object type has User.id even though that field doesn't exist.

User.username is also nullable in the GraphQL schema even though it is the key.

JoviDeCroock commented 9 months ago

the key prop is used to generate the id property. A node needs a key and you are telling us that we can generate that from username. This is intended behaviour, it's true however that a nullable field should warn in ts.

We translate __typename:values[key] to the id property

mxstbr commented 9 months ago

Ohh, that makes a ton of sense!