-
Notifications
You must be signed in to change notification settings - Fork 66
Closed
Description
Is your feature request related to a problem? Please describe.
This issue is spun out of a discussion on Gitter with @liiight:
@prkumar i have a question. I wanna do something like this:
class Lestrade(FlapiBase): @lestrade_error @json @post('lestrade/graphql') def graphql(self, **body: Body): pass @returns.json(member=('data', 'incidents')) def get_incident(self, **body) -> Incident: return self.graphql(**body) @returns.json(member=('data', 'updateIncident')) def update_incident(self, **body: Body) -> UpdateCommandResponse: return self.graphql(**body)
Essentially, we want two separate "child" consumer methods that "inherit" details from the graphql consumer method.
Describe the solution you'd like
In summary, we can use the graphql consumer method as a decorator on subsequent methods in the class definition so that they can inherit and enhance the request definition, separately. (This should be actually pretty simple to implement.)
class Lestrade(FlapiBase):
@lestrade_error
@json
@post('lestrade/graphql')
def graphql(self, **body: Body):
pass
@returns.json(member=('data', 'incidents'))
@graphql
def get_incident(self, **body) -> Incident:
pass
@returns.json(member=('data', 'updateIncident'))
@graphql
def update_incident(self, **body) -> UpdateCommandResponse:
passNotably, the decorated methods need to have the same argument signature as the graphql method.