Hi! I’m curious how folks handle the separation of...
# graphql-kotlin
a
Hi! I’m curious how folks handle the separation of data classes used for the graphql schema vs data classes used as e.g. DTOs. Like, we have a service that owns a
User
type that we want to expose internally to other services for e.g. authentication (this would be the DTO), but we also want that data in the graphql schema. Is it as simple as having two data classes, maybe the latter with some
GQL
prefix or something?
this sort of question could also be extended to include e.g. exposed’s DAOs
r
instead of prefixing the data class for GQL explicitly, we’re sticking all the GQL models into a separate package
we wanted a very clear distinction between, “internal API classes, modify at will” and “external facing GQL types. modify carefully”
and having them in separate packages, and therefore in separate files, helps us with that
r
We do the same thing as @Ryan Smith, but liberally use the internal types inside the GraphQL API types. That way we get as much re-use as possible, but its always possible to maintain compat at the API level if the internal types change.