Closed trixobird closed 1 year ago
Hello @trixobird , you are right: the generated shape of Subscription is incorrect. I will make an update soon.
It is supposed to look like this:
// Option 1 - Will be in the next fix
export const bookReadEvent: NonNullable<SubscriptionResolvers["bookReadEvent"]> = {
subscribe: async (_parent, _arg, _ctx) => {
// ... Subscription implementation here
},
};
// Option 2
export const bookReadEvent: NonNullable<SubscriptionResolvers["bookReadEvent"]> = () => ({
subscribe: async (_parent, _arg, _ctx) => {
// ... Subscription implementation here
},
});
For your current issue, are you following the Subscription guide on GraphQL Yoga? If so, can you try this and see if it works:
export const bookReadEvent: NonNullable<SubscriptionResolvers["bookReadEvent"]> = {
subscribe: () => pubSub.subscribe('userLoginChanged'),
resolve: (payload) => payload
};
I have released an alpha version to fix the default Subscription resolver generation issue.
If you have a chance, do you mind trying it out:
yarn add @eddeee888/gcg-typescript-resolver-files@pr73-run161-1
export const bookReadEvent: NonNullable<SubscriptionResolvers["bookReadEvent"]> = {
subscribe: async (_parent, _arg, _ctx) => {
/* Implement Subscription.bookReadEvent resolver logic here */
},
};
export const bookReadEvent: NonNullable<SubscriptionResolvers["bookReadEvent"]> = {
subscribe: () => pubSub.subscribe('userLoginChanged'),
resolve: (payload) => payload
};
Let me know how you go! :)
Hi @trixobird , does the alpha version work for you? :)
Version 0.4 has a fix for this. Please try and let me know if there's still a problem
yarn add -D @eddeee888/gcg-typescript-resolver-files@0.4.0
I followed the guild.dev guide and everything were good. So in book/schema.graphql I added
and upon generation I got a new filew in book/Subscription folder named bookReadEvent.ts
I am not able to make it work as a function, nomatter what I added there. For example when I put this
I was getting
right when I executing the subsription call. I was able to make to work like this:
where pubSub is
The generated type support both, so it seems that I am missing something. Could you help me please? Happy to add it to documentation afterwards as example.