mst-gql icon indicating copy to clipboard operation
mst-gql copied to clipboard

Support Multiple fields with type `ID`

Open chrisdrackett opened this issue 5 years ago • 8 comments

right now we only expect a single ID field. However, in the case a user has more than one ID field on an object mst-gql will not know which one is the ID for the object.

This issue covers updating the config or similar to support letting mst-gql know which is the canonical ID for any model that has more than one ID.

We should provide a clear error during scaffold that we ran into this and give the users steps to fix it.

chrisdrackett avatar May 02 '20 00:05 chrisdrackett

Something additional to consider: not all schemas use ID as the type for ID (Hasura, for example, could have a uuid as the ID type).

mwarger avatar May 07 '20 02:05 mwarger

I'm confused, they use something other than ID in the graphQL schema? what is the logic behind this?

chrisdrackett avatar May 07 '20 15:05 chrisdrackett

@mwarger oh, is that why I always get

Uncaught Error: Failed to resolve reference 43e8a390-9447-11ea-8ccb-19e3a3dddd88 to late(function () {
    return _gartenModel__WEBPACK_IMPORTED_MODULE_11__["gartenModel"];
  })

when trying to select fields in referenced tables?

My project uses hasura. And yes, id fields are declared as uuid!.

So far I thought I was still doing something wrong but after trying for hours I have still not succeeded to solve this issue.

I guess this will become a blocker for me soon.

barbalex avatar May 12 '20 12:05 barbalex

related issue: https://github.com/mobxjs/mst-gql/issues/215. Well, actually, that on is about the field name, not type.

barbalex avatar May 12 '20 12:05 barbalex

Actually there is an issue just about hasura not using type ID: https://github.com/mobxjs/mst-gql/issues/92

barbalex avatar May 12 '20 12:05 barbalex

good point, I feel like we could fix both these issues with a single fix of optimally specifying an ID via config.

/cc @beepsoft

chrisdrackett avatar May 12 '20 15:05 chrisdrackett

@chrisdrackett I am interested in implementing this if it's a feature we feel is still needed.

How do you feel about the proposal in this comment? https://github.com/mobxjs/mst-gql/issues/92#issue-493537797

Metevier avatar Jul 06 '20 15:07 Metevier

@Metevier I'm all for this! We don't run into this ourselves, so I don't have a lot of ideas around the best way to handle it, but seems like a place where we can add some optional flexibility!

chrisdrackett avatar Jul 07 '20 22:07 chrisdrackett