File tree Expand file tree Collapse file tree 4 files changed +24
-273
lines changed Expand file tree Collapse file tree 4 files changed +24
-273
lines changed Original file line number Diff line number Diff line change 22Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
33exports . UserRoles = void 0 ;
44const common_1 = require ( "@nestjs/common" ) ;
5- const graphql_1 = require ( "@nestjs/graphql" ) ;
65function userFactory ( ctx ) {
76 const contextType = ctx . getType ( ) ;
87 if ( contextType === 'http' ) {
@@ -19,8 +18,10 @@ function userFactory(ctx) {
1918 throw new Error ( 'Websockets context is not implemented yet' ) ;
2019 }
2120 else if ( ctx . getType ( ) === 'graphql' ) {
21+ // inline require here, since we don't want to require the graphql module in the pacakge.
22+ const { GqlExecutionContext } = require ( '@nestjs/graphql' ) ;
2223 // do something that is only important in the context of GraphQL requests
23- const gqlExecutionContext = graphql_1 . GqlExecutionContext . create ( ctx ) ;
24+ const gqlExecutionContext = GqlExecutionContext . create ( ctx ) ;
2425 return gqlExecutionContext . getContext ( ) . req . user ;
2526 }
2627 throw new Error ( 'Invalid context' ) ;
Original file line number Diff line number Diff line change 2828 "devDependencies" : {
2929 "@nestjs/common" : " ^7.6.18" ,
3030 "@nestjs/core" : " ^7.6.18" ,
31- "@nestjs/graphql" : " ^9.1.2" ,
3231 "@nestjs/testing" : " ^7.6.18" ,
3332 "@types/jest" : " ^27.0.0" ,
3433 "@types/node" : " ^10.1.2" ,
3534 "coveralls" : " ^3.0.1" ,
36- "graphql" : " 15.0.0" ,
3735 "gulp" : " ^4.0.0" ,
3836 "gulp-sequence" : " ^1.0.0" ,
3937 "gulp-typescript" : " ^5.0.1" ,
5351 "accesscontrol" : " ^2.2.1"
5452 },
5553 "peerDependencies" : {
56- "@nestjs/graphql" : " ^9.1.2"
54+ "graphql" : " 15.0.0" ,
55+ "@apollo/gateway" : " ^0.45.1" ,
56+ "@nestjs/graphql" : " ^7.6.18" ,
57+ "apollo-server-core" : " ^3.6.1" ,
58+ "ts-morph" : " ^13.0.2"
5759 }
5860}
Original file line number Diff line number Diff line change 11import { createParamDecorator , ExecutionContext } from '@nestjs/common' ;
2- import { GqlContextType , GqlExecutionContext } from '@nestjs/graphql' ;
32import { Role } from '..' ;
43
54function userFactory < T > ( ctx : ExecutionContext ) : T {
@@ -14,7 +13,9 @@ function userFactory<T>(ctx: ExecutionContext): T {
1413 } else if ( contextType === 'ws' ) {
1514 // do something that is only important in the context of Websockets requests
1615 throw new Error ( 'Websockets context is not implemented yet' ) ;
17- } else if ( ctx . getType < GqlContextType > ( ) === 'graphql' ) {
16+ } else if ( contextType === 'graphql' ) {
17+ // inline require here, since we don't want to require the graphql module in the pacakge.
18+ const { GqlExecutionContext } = require ( '@nestjs/graphql' ) ;
1819 // do something that is only important in the context of GraphQL requests
1920 const gqlExecutionContext = GqlExecutionContext . create ( ctx ) ;
2021 return gqlExecutionContext . getContext ( ) . req . user ;
You can’t perform that action at this time.
0 commit comments