API schema
and database schemas
are decoupled within GraphQL landscape.
resolver
can be used to create a missing country
field on an address
schema even when it is missing in the database.This is why a type
can transform across the layers in the architecture.
client
layer is different than on the server
layer.At times, even data layer
types and server layer
types may be different for the same field
uuid
type while server would interpret it just as a string
typeData
to Service
LayerWhen the data is pulled as a response to a request, it first gets pulled from the database
to the repository layer
repository
layer should mirror the DB Schema because we're simply pulling the data-layer into the server layer at this stepRepository layer
method is then called by the service layer
method
Service layer should NOT do everything needed to fulfill the graphql schema expectations
Service
LayerShape the
return shape
in theresolver
, not in other parts of the service layer
When you need to define a graph connection of a field, you must do this in the resolver
layer
server layer
resolver layer
If you don't place the relationships in the resolver layer, you are violating domain boundary and entangling the relationship in domain definition, not based on return
// resolver return shape { primitiveField1: UUID, primitiveField2: number, // return type of service1.getMethod relationshipField1: service1.getMethod(), // return type of service2.getMethod relationshipField2: service2.getMethod() }