d-exclaimation / pioneer

GraphQL for Swift.
https://pioneer.dexclaimation.com
Apache License 2.0
40 stars 8 forks source link

Field Resolve Middleware #119

Closed d-exclaimation closed 1 year ago

d-exclaimation commented 1 year ago

Is your feature request related to a problem? Please describe. It will be nice to have a middleware-like feature but are for individuals resolver basis and not the entirety of server level.

Describe the solution you'd like

  1. Extensions to Graphiti Field to allow middleware

    Field("field1", at: Resolve.field1, use: [Middleware1, Middleware2, Middleware3]) {
    Argument("arg1", at: \.arg1)
    }
  2. Wrapped for field resolvers to apply middleware

Field("field1", at: withMiddleware(Resolver.field1, use: Middleware1, Middleware2, Middleware3)) {
    Argument("arg1", at: \.arg1)
}

Describe alternatives you've considered Implement this on Graphiti level

Field("field1", at: Resolve.field1) {
    Argument("arg1", at: \.arg1)
}
.middleware(use: Middleware1, Middleware2, Middleware3)
d-exclaimation commented 1 year ago

I think I can definitely do the first 2, I'll look into which is more practical and then I can maybe add this to Graphiti as a feature request there as the last approach is definitely a better API