I am trying to setup subscriptions and need some additional logic around connecting the client to the server using Websockets. After reading the docs on the subscription.onConnect method the return type is supposed to be "truthy" OR and object. When using mericurius in a TypeScript project the return type is set to Record<string, any> | Promise<Record<string, any>> but this will not allow for returning true/false which seem ok according to both the docs and the code itself.
The docs clearly states that:
subscription.onConnect: Function A function which can be used to validate the connection_init payload. If defined it should return a truthy value to authorize the connection. If it returns an object the subscription context will be extended with the returned object.
Returning true/false in onConnect gives me the functionality I need but TypeScript is not happy with that. How are you supposed to return a truthy OR falsy value when the return type is set to Record<string, any> | Promise<Record<string, any>>? I would propose extending the return type with boolean to handle this inconsistency.
I am trying to setup subscriptions and need some additional logic around connecting the client to the server using Websockets. After reading the docs on the
subscription.onConnect
method the return type is supposed to be "truthy" OR and object. When using mericurius in a TypeScript project the return type is set toRecord<string, any> | Promise<Record<string, any>>
but this will not allow for returning true/false which seem ok according to both the docs and the code itself.The docs clearly states that:
Returning true/false in onConnect gives me the functionality I need but TypeScript is not happy with that. How are you supposed to return a truthy OR falsy value when the return type is set to
Record<string, any> | Promise<Record<string, any>>
? I would propose extending the return type withboolean
to handle this inconsistency.