Get the data type of a node with a given ID?


#1

I want to implement a permissions/sharing system that is type-agnostic. Basically a user can specify a list of IDs and share access to all of those entities with another user. To do so, I’m trying to determine the type of each entity (given it’s ID). Is this possible?


#2

I don’t quite get it. Can you share an example schema that you have in mind?


#3
type Person {
  id: ID!
}

type Event {
  id: ID!
}

That’s basically it - two different types. Every event or person has a unique ID that prisma generates. I have a list of IDs but I don’t know whether each ID is referring to a Person or an Event. Is there a way to determine the type of an entity based only on the ID?


#4

I think you will require a more custom approach here:

type Person {
  id: ID!
 uid: String! @unique
}

type Event {
  id: ID!
uid: String! @unique
}

Now you can generate event-dsalkfj and user-asdasd in you own codebase.


#5

Hm, too bad. I like your proposed approach though! Thanks Harshit!