Replies: 1 comment
-
It's caused by my typegraphql backend type defination was incorrect,and then graphql codegen in frontend generated the wrong return type for my subscription.Already fixed |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I 'am try to send a nested Document to my urql subscription as payload and then using that data Updating frontend ui,but I just got this Error
CombinedError: [GraphQL] ObjectIdScalar can only serialize ObjectId values at makeResult (urql-core-chunk.mjs:235:1) at Object.nextResult [as next] (urql-core.mjs:419:39) at eval (client.mjs:233:1)
Who can help me solved this problem please?
Here's my backend payload type:
`export type populatedConversation = {
_id: ObjectId;
participants: Participant[];
participantUserIds: string[];
messages: Message[];
createdAt: Date;
updatedAt?: Date;
lastestMessageId?: string;
latestMessage?: Message[];
};
export interface ConversationUpdatedPayload {
conversationUpdated: {
conversation: populatedConversation;
addedUserIds?: string[];
removedUserIds?: string[];
};
}`
frontend subscription code in useEffect hook:
const conversationUpdatedSub = client .subscription<ConversationUpdatedSubscription>( ConversationUpdatedDocument, { conversationId, } ) .subscribe((res) => { if (res.data) { console.log( 'conversation updated data:', res.data.conversationUpdated ) queryClient.invalidateQueries(['conversations', 'messages']) } if (res.error) { console.log('conversation updated error:', res.error) conversationUpdatedSub.unsubscribe() } })
Beta Was this translation helpful? Give feedback.
All reactions