Mutations with resolvers inheritance #1029
Replies: 1 comment 1 reply
-
export const createRecordResolver = <
T extends Record,
Input extends Partial<T>
>(
objectTypeCls: ClassType<T>,
inputTypeCls: ClassType<Input>
) => {
@Resolver({ isAbstract: true })
abstract class BaseResolver {
@Mutation((type) => objectTypeCls)
async createRecord(@Arg('record', () => inputTypeCls) recordInput: Input) {
console.log(recordInput);
}
}
return BaseResolver;
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jpbarbosa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was able to implement resolvers inheritance following the docs and the example on GitHub, but both only show how to implement queries, and I'd like to inheritance mutations.
When I tried it by myself, I got an error in the argument "record":
Inheritance is great for common CRUD operations and would be great to see mutations examples on the documentation.
Docs: https://typegraphql.com/docs/0.17.0/inheritance.html#resolvers-inheritance
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions