Skip to main content

Class: GraphQLWatcher

Defined in: watchers/graphql/graphql.watcher.ts:60

Implements​

  • OnModuleInit
  • OnApplicationBootstrap
  • OnModuleDestroy

Constructors​

Constructor​

new GraphQLWatcher(collector, nestlensConfig, moduleRef): GraphQLWatcher

Defined in: watchers/graphql/graphql.watcher.ts:72

Parameters​

collector​

CollectorService

nestlensConfig​

NestLensConfig

moduleRef​

ModuleRef

Returns​

GraphQLWatcher

Methods​

destroy()​

destroy(): void

Defined in: watchers/graphql/graphql.watcher.ts:434

Cleanup resources

Returns​

void


detectServer()​

detectServer(): DetectedServer

Defined in: watchers/graphql/graphql.watcher.ts:270

Detect which GraphQL server is installed

Returns​

DetectedServer


getAdapter()​

getAdapter(): BaseGraphQLAdapter | undefined

Defined in: watchers/graphql/graphql.watcher.ts:384

Get the active adapter

Returns​

BaseGraphQLAdapter | undefined


getConfig()​

getConfig(): ResolvedGraphQLConfig

Defined in: watchers/graphql/graphql.watcher.ts:377

Get the current configuration

Returns​

ResolvedGraphQLConfig


getPlugin()​

getPlugin(): unknown

Defined in: watchers/graphql/graphql.watcher.ts:353

Get the GraphQL plugin to register with the server

For Apollo Server:

const apolloServer = new ApolloServer({
plugins: [graphqlWatcher.getPlugin()],
});

For Mercurius:

fastify.register(mercurius, {
hooks: graphqlWatcher.getPlugin(),
});

Returns​

unknown


getRegistrationMode()​

getRegistrationMode(): RegistrationMode

Defined in: watchers/graphql/graphql.watcher.ts:427

Get the current registration mode

Returns​

RegistrationMode


getStats()​

getStats(): object

Defined in: watchers/graphql/graphql.watcher.ts:457

Get statistics

Returns​

object

adapterType?​

optional adapterType: string

initialized​

initialized: boolean

registrationMode​

registrationMode: RegistrationMode

subscriptions?​

optional subscriptions: object

subscriptions.totalConnections​

totalConnections: number

subscriptions.totalSubscriptions​

totalSubscriptions: number


getSubscriptionTracker()​

getSubscriptionTracker(): SubscriptionTracker | undefined

Defined in: watchers/graphql/graphql.watcher.ts:370

Get the subscription tracker for WebSocket integration

Returns​

SubscriptionTracker | undefined


initialize()​

initialize(): void

Defined in: watchers/graphql/graphql.watcher.ts:236

Initialize the GraphQL watcher.

There were two of these, one async and one not, running the same eight steps — and they had already drifted: the lazy one, reached through getPlugin(), returned silently when no GraphQL server was found. A project wiring the plugin by hand against a server NestLens could not detect got an empty plugin object and no reason for it, which presents as "the watcher is on and records nothing". Nothing here awaits, so the one that remains does not pretend to.

Returns​

void


isAutoRegistered()​

isAutoRegistered(): boolean

Defined in: watchers/graphql/graphql.watcher.ts:420

Check if the plugin was auto-registered

Returns​

boolean


isInitialized()​

isInitialized(): boolean

Defined in: watchers/graphql/graphql.watcher.ts:391

Check if the watcher is initialized

Returns​

boolean


markAutoRegistered()​

markAutoRegistered(): void

Defined in: watchers/graphql/graphql.watcher.ts:399

Mark the plugin as auto-registered. Called by NestLensApolloPlugin or MercuriusAutoRegistrar when auto-registration succeeds.

Returns​

void


markManuallyRegistered()​

markManuallyRegistered(): void

Defined in: watchers/graphql/graphql.watcher.ts:410

Mark the plugin as manually registered. Called when getPlugin() is accessed for manual integration.

Returns​

void


onApplicationBootstrap()​

onApplicationBootstrap(): void

Defined in: watchers/graphql/graphql.watcher.ts:157

Wires subscription tracking, once the schema exists.

GraphQLModule builds the schema during its own initialisation, so there is nothing to instrument at onModuleInit. This runs after every module has started, which is the first moment the schema is there to be read.

Returns​

void

Implementation of​

OnApplicationBootstrap.onApplicationBootstrap


onModuleDestroy()​

onModuleDestroy(): void

Defined in: watchers/graphql/graphql.watcher.ts:221

Cleanup on module destroy

Returns​

void

Implementation of​

OnModuleDestroy.onModuleDestroy


onModuleInit()​

onModuleInit(): void

Defined in: watchers/graphql/graphql.watcher.ts:92

Initialize the watcher on module init

Returns​

void

Implementation of​

OnModuleInit.onModuleInit