Skip to content

Circular Ref Error while useServer generates context on 'onConnect' #360

Answered by enisdenjo
berkaytheunicorn asked this question in Q&A
Discussion options

You must be logged in to vote

Object value returned from onConnect is the ConnectionAck payload that gets sent to the client, it must be JSON stringified (see documentation for onConnect).

I guess you want to create a GraphQL operation context, for that you should use the context server option instead.

this.serverCleanup = useServer(
        {
          schema,
-         onConnect: async (connectionContext) => {
-           const { connectionParams, extra } = connectionContext;
-           this.log.info("CONNECTED");
-           const context = await this.context(null, connectionParams);
-           await this.clientDidConnect(connectionParams, extra.socket, context);
-
-           return context  // <<< here my conte…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by berkaytheunicorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #359 on May 09, 2022 09:49.