-
I am using the typescript-resolvers plugin to generate the types for the resolvers. In my schema I have
so I tried to define my resolvers somwhat like this const resolvers: IResolvers = {
...
Subscription: {
addedBook: {
subscribe: ...,
resolve: (source, args, context, info) => ...
},
}
} I would normally expect Interestingly when looking in the generated file, export type SubscriptionObject<TResult, TKey extends string, TParent, TContext, TArgs> =
| SubscriptionSubscriberObject<TResult, TKey, TParent, TContext, TArgs>
| SubscriptionResolverObject<TResult, TParent, TContext, TArgs>; When I comment out one of the two (parameter) source: {
addedBook: ResolverTypeWrapper<IBookModel>;
} which is wrong. It would have to be My codengen.yml: overwrite: true
schema: "./server/src/schema.graphql"
generates:
./server/src/types/graphql.ts:
config:
contextType: ./models#IContext
typesPrefix: I
useIndexSignature: true
mappers:
Author: ./models#IAuthorModel
Book: ./models#IBookModel
plugins:
- "typescript"
- "typescript-resolvers" Can someone explain this to me? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think that's correct. |
Beta Was this translation helpful? Give feedback.
-
Opening this back up, I do think this type is incorrect:
Shouldn't those ie.
Maybe I'm missing some configuration in my codgen? |
Beta Was this translation helpful? Give feedback.
I think that's correct.
subscribe
needs to receive an object that contains the result with a property name that is same as the name of the root field. In your case; the result ofaddedBook
's subscribe method should return something like{ addedBook: IBookModel}
.If you still think that's incorrect, please share an actual implementation with a real server in CodeSandbox.