I have this configuration with GraphQL and Dynamoose modules, the graphql module is using the follo context:
context: ({req}: { req: Request }) => ({req}),
However this context in not shared with Dynamoose revolvers, is marked as undefined, but if the context is shared as object is possible to use, but I need the graphql context based on requests:
context: {
user: 'jose'
},
But in the final implementation the request are not shared.
References: https://github.com/hardyscc/nestjs-dynamoose
https://github.com/hardyscc/aws-nestjs-starter
@Query(/* istanbul ignore next */ () => [Notification])
notificationByTargetId(
@Args('targetId') targetId: string,
@Context('user') user,
) {
console.log('findByTargetId')
return this.notificationService.findByTargetId(targetId, user);
}
import { NotificationModule } from './modules/notification/notification.module';
@Module({
imports: [
ConfigModule.forRoot(),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
autoSchemaFile: true,
playground: true,
context: ({req}: { req: Request }) => ({req}),
}),
DynamooseModule.forRoot({
local: process.env.IS_DDB_LOCAL === 'true',
aws: { region: process.env.REGION },
table: {
create: process.env.IS_DDB_LOCAL === 'true',
prefix: `${process.env.SERVICE}-${process.env.STAGE}-`,
suffix: '-table',
},
}),
NotificationModule,
DefaultFilterConfigurationModule,
],
})
export class AppModule {}