prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Custom, non-entity backed types

Open davemcorwin opened this issue 9 years ago • 6 comments

Possibly related to #79 and #77

It would be nice to be able to create custom types that can be used in other type definitions, but do not correspond to a resource/permissions on their own. The current workaround is to either use the Json scalar type, but then we lose the benefit of type-checking, or create a normal type and associated relationships which adds a lot of unnecessary noise.

Ex.

type Location {
  address: String!
  city: String!
}

type Person {
  name: String!
  location: Location!
}

type Business {
  url: String!
  location: Location!
}

davemcorwin avatar Jul 11 '17 16:07 davemcorwin

I can confirm that we had a lot of real-world use for a feature like this on a different graphqlAAS provider.

FreddieRidell avatar Aug 02 '17 12:08 FreddieRidell

This feature is even more useful/important with the recent addition of resolver functions. See also #318.

marktani avatar Aug 02 '17 12:08 marktani

This is very useful. We have to add A LOT of on-to-one relations to support nested fields. And in some instances we just have to fallback to JSON because there is no other way

alexeygolev avatar Oct 05 '17 17:10 alexeygolev

These could even be used as storage types, with storage set to 'parent', meaning it will actually be stored as Json on the parent type. But the most obvious examples are of course resolver functions.

kbrandwijk avatar Oct 05 '17 19:10 kbrandwijk

Closing in favour of #1160.

schickling avatar Nov 03 '17 23:11 schickling

@alexeygolev It would be very helpful if you could describe a case where JSON is currently the only option, but embedded types as described here would work.

sorenbs avatar Nov 12 '17 22:11 sorenbs