Closed d-exclaimation closed 1 year ago
Note This is a lower priority change, it doesn't need to be merged right away
Subclassing declaration would have more boilerplate than Instance based declaration
let AuthSchema = PartialSchema<Resolver, Context>( types: { Type(User.self) { Field("id", at: \.id) Field("name", at: \.name) Field("email", at: \.email) Field("orders", at: User.orders, as: [TypeReference<Order>].self) } Type(Credential.self) { Field("token", at: \.token) Field("expiresAt", at: \.expiresAt) Field("user", at: \.user) } }, query: { Field("me", at: Resolver.me) }, mutation: { Field("login", at: Resolver.login) Field("signup", at: Resolver.signup) } ) let OrderSchema = PartialSchema<Resolver, Context>( types: { Type(Order.self) { Field("id", at: \.id) Field("quantity", at: \.quantity) Field("cost", at: \.cost) Field("user", at: Order.user) Field("status", at: Order.currentStatus, as: TypeReference<Status>?.self) Field("progress", at: Order.progress, as: [TypeReference<Status>].self) } Type(Status.self) { Field("distance", at: \.distance) Field("progress", at: \.progress) Field("order", at: Status.order) } }, query: { Field("order", at: Resolver.orderById) { Argument("id", at: \.id) } }, mutation: { Field("createOrder", at: Resolver.createOrder) { Argument("quantity", at: \.quantity) } } ) let schema = try Schema.create(from: [AuthSchema, OrderSchema])
Also I updated the README with examples to use PartialSchema
I saw that and I love it!
@NeedleInAJayStack Mind doing the release again?
Sure, no problem
Changes overview
Reasoning
Subclassing declaration would have more boilerplate than Instance based declaration
Example