You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Graphql and http, so in some interceptors and guards I have to check if the conext is of graphql type, but when I do ctxType == 'graphql' I get This comparison appears to be unintentional because the types 'ContextType' and '"graphql"' have no overlap.
Can you add 'graphql' to ContextType in @nestjs\common\interfaces\features\arguments-host.interface.d.ts
Make a guard, interceptor or anything that has context of type ExecutionContext, and try to check the type of context doing something like:
const type = context.getType();
let request;
if (type == 'graphql') { // < -- Error here
const ctx = GqlExecutionContext.create(context);
request = ctx.getContext().req;
} else {
// ...
}
Expected behavior
context.getType() should accepte all these 'http' | 'rpc' | 'ws' | 'graphql'
My current fix is const type: 'http' | 'rpc' | 'ws' | 'graphql' = context.getType();
Is there an existing issue for this?
Current behavior
I'm using Graphql and http, so in some interceptors and guards I have to check if the conext is of graphql type, but when I do
ctxType == 'graphql'
I getThis comparison appears to be unintentional because the types 'ContextType' and '"graphql"' have no overlap
.Can you add
'graphql'
toContextType
in@nestjs\common\interfaces\features\arguments-host.interface.d.ts
export type ContextType = 'http' | 'ws' | 'rpc';
Minimum reproduction code
https://github.com/azuziii/issue-graphql-nest/blob/main/guard.ts
Steps to reproduce
Make a guard, interceptor or anything that has context of type
ExecutionContext
, and try to check the type of context doing something like:Expected behavior
context.getType()
should accepte all these'http' | 'rpc' | 'ws' | 'graphql'
My current fix is
const type: 'http' | 'rpc' | 'ws' | 'graphql' = context.getType();
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
10.4.5
Packages versions
Node.js version
20.17.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: