Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6f3dccd
fix(graphql): change info to nullable
niamu01 Sep 22, 2024
8b141c5
fix(graphql,apollo): ensures extensions are added to resolved fields
thiagomini Jan 2, 2026
3b443c4
fix(apollo): respect useglobalprefix on custom subscription path
maruthang Apr 19, 2026
2e8dc68
fix(@nestjs/graphql): keep resolvers required when skipping args
yogeshwaran-c Apr 21, 2026
26a9ce7
Merge pull request #3945 from yogeshwaran-c/fix/skip-resolver-args-op…
kamilmysliwiec Apr 23, 2026
dcd03cb
Merge pull request #3937 from maruthang/fix/issue-2477-subscription-g…
kamilmysliwiec Apr 23, 2026
c6dac18
Merge pull request #3779 from thiagomini/fix/fix-extensions-in-resolv…
kamilmysliwiec Apr 23, 2026
5bc951b
Merge pull request #3314 from niamu01/niamu01-fix/MiddlewareContext-i…
kamilmysliwiec Apr 23, 2026
ab58b91
test: migrate jest assertions to vitest
kamilmysliwiec Apr 23, 2026
f68ca18
chore: remove subscriptions-transport-ws
kamilmysliwiec May 5, 2026
b56a80e
Merge branch 'master' into v14.0.0
kamilmysliwiec May 5, 2026
a3f2044
Merge pull request #3971 from nestjs/chore/remove-subscriptions-trans…
kamilmysliwiec May 5, 2026
d8fb33a
chore: remove apollo playground
kamilmysliwiec May 5, 2026
ad48609
Merge pull request #3972 from nestjs/chore/remove-apollo-playground
kamilmysliwiec May 5, 2026
f217eff
chore: migrate to esm
kamilmysliwiec May 6, 2026
ce11172
Merge pull request #3976 from nestjs/chore/esm-migration
kamilmysliwiec May 6, 2026
75849ca
fix(@nestjs/graphql): preserve federation directives in autoschemafile
maruthang Apr 30, 2026
d776371
chore: rebase to v14.0.0
kamilmysliwiec May 12, 2026
5a7317a
Merge branch 'maruthang-fix/issue-3722-federation-sdl-generation' int…
kamilmysliwiec May 12, 2026
347a734
Merge branch 'master' into v14.0.0
kamilmysliwiec May 14, 2026
2c9e169
chore: install next nestjs packages
kamilmysliwiec May 14, 2026
bf2bdd3
chore: minor tweaks
kamilmysliwiec May 14, 2026
d082730
chore(deps): migrate to es-toolkit from lodash
kamilmysliwiec May 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion packages/apollo/lib/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './apollo.constants';
export * from './apollo.constants.js';
2 changes: 1 addition & 1 deletion packages/apollo/lib/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './plugin.decorator';
export * from './plugin.decorator.js';
2 changes: 1 addition & 1 deletion packages/apollo/lib/decorators/plugin.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { PLUGIN_METADATA } from '../constants';
import { PLUGIN_METADATA } from '../constants/index.js';

/**
* Decorator that marks a class as an Apollo plugin.
Expand Down
67 changes: 37 additions & 30 deletions packages/apollo/lib/drivers/apollo-base.driver.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { ApolloServer, type BaseContext } from '@apollo/server';
import { ApolloServerPluginLandingPageGraphQLPlayground } from '@apollo/server-plugin-landing-page-graphql-playground';
import {
ApolloServerErrorCode,
unwrapResolverError,
} from '@apollo/server/errors';
import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled';
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
import { HttpStatus } from '@nestjs/common';
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { isFunction } from '@nestjs/common/utils/shared.utils';
import { loadPackage } from '@nestjs/common/utils/load-package.util.js';
import { isFunction } from '@nestjs/common/utils/shared.utils.js';
import { AbstractGraphQLDriver } from '@nestjs/graphql';
import { GraphQLError, GraphQLFormattedError } from 'graphql';
import omit from 'lodash.omit';
import { GraphiQLPlaygroundPlugin } from '../graphiql/graphiql-playground.plugin';
import { GraphiQLOptions } from '../graphiql/interfaces/graphiql-options.interface';
import { ApolloDriverConfig } from '../interfaces';
import { createAsyncIterator } from '../utils/async-iterator.util';
import { GraphiQLPlaygroundPlugin } from '../graphiql/graphiql-playground.plugin.js';
import { GraphiQLOptions } from '../graphiql/interfaces/graphiql-options.interface.js';
import { ApolloDriverConfig } from '../interfaces/index.js';
import { createAsyncIterator } from '../utils/async-iterator.util.js';

const apolloPredefinedExceptions: Partial<Record<HttpStatus, string>> = {
[HttpStatus.BAD_REQUEST]: ApolloServerErrorCode.BAD_REQUEST,
Expand Down Expand Up @@ -57,7 +56,14 @@ export abstract class ApolloBaseDriver<
stopOnTerminationSignals: false,
};

if (options.graphiql) {
const useGraphiQL =
options.graphiql ||
options.playground === true ||
(options.graphiql === undefined &&
options.playground === undefined &&
process.env.NODE_ENV !== 'production');

if (useGraphiQL) {
const graphiQlPlaygroundOpts: GraphiQLOptions =
typeof options.graphiql === 'object' ? options.graphiql : {};
graphiQlPlaygroundOpts.url ??= options.path;
Expand All @@ -66,21 +72,6 @@ export abstract class ApolloBaseDriver<
...defaults,
plugins: [new GraphiQLPlaygroundPlugin(graphiQlPlaygroundOpts)],
};
} else if (
(options.playground === undefined &&
process.env.NODE_ENV !== 'production') ||
options.playground
) {
const playgroundOptions =
typeof options.playground === 'object' ? options.playground : undefined;
defaults = {
...defaults,
plugins: [
ApolloServerPluginLandingPageGraphQLPlayground(
playgroundOptions,
) as any,
],
};
} else if (
(options.playground === undefined &&
process.env.NODE_ENV === 'production') ||
Expand All @@ -101,6 +92,7 @@ export abstract class ApolloBaseDriver<
defaults.plugins || [],
);

this.normalizeSubscriptionsPath(options);
this.wrapContextResolver(options);
this.wrapFormatErrorFn(options);

Expand All @@ -113,6 +105,22 @@ export abstract class ApolloBaseDriver<
return options;
}

private normalizeSubscriptionsPath(options: T) {
const subscriptions = (options as ApolloDriverConfig).subscriptions;
if (!subscriptions) {
return;
}
for (const protocol of [
'graphql-ws',
'subscriptions-transport-ws',
] as const) {
const config = subscriptions[protocol];
if (config && typeof config === 'object' && config.path) {
config.path = this.applyGlobalPrefix(config.path, options);
}
}
}

public subscriptionWithFilter(
instanceRef: unknown,
filterFn: (
Expand All @@ -134,7 +142,7 @@ export abstract class ApolloBaseDriver<
options: T,
{ preStartHook }: { preStartHook?: () => void } = {},
) {
const { expressMiddleware } = loadPackage(
const { expressMiddleware } = await loadPackage(
'@as-integrations/express5',
'GraphQLModule',
() => require('@as-integrations/express5'),
Expand All @@ -144,7 +152,7 @@ export abstract class ApolloBaseDriver<

const httpAdapter = this.httpAdapterHost.httpAdapter;

// Workaround: GraphQL playground requires body to be present
// Workaround: the landing page requires body to be present
// otherwise, it shows the "req.body is not set; this probably means you forgot to set up the json middleware before the Apollo Server middleware." error.
// The latest version of "body-parser" does not set the body if there is no payload.
// @see https://github.com/nestjs/graphql/issues/3451
Expand Down Expand Up @@ -187,11 +195,10 @@ export abstract class ApolloBaseDriver<
options: T,
{ preStartHook }: { preStartHook?: () => void } = {},
) {
const { fastifyApolloDrainPlugin, fastifyApolloHandler } = loadPackage(
'@as-integrations/fastify',
'GraphQLModule',
() => require('@as-integrations/fastify'),
);
const { fastifyApolloDrainPlugin, fastifyApolloHandler } =
await loadPackage('@as-integrations/fastify', 'GraphQLModule', () =>
require('@as-integrations/fastify'),
);

const httpAdapter = this.httpAdapterHost.httpAdapter;
const app = httpAdapter.getInstance();
Expand Down
12 changes: 6 additions & 6 deletions packages/apollo/lib/drivers/apollo-federation.driver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common';
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { loadPackage } from '@nestjs/common/utils/load-package.util.js';
import { ModulesContainer } from '@nestjs/core';
import {
extend,
Expand All @@ -8,9 +8,9 @@ import {
SubscriptionConfig,
} from '@nestjs/graphql';
import { GraphQLSchema } from 'graphql';
import { ApolloDriverConfig } from '../interfaces';
import { PluginsExplorerService } from '../services/plugins-explorer.service';
import { ApolloBaseDriver } from './apollo-base.driver';
import { ApolloDriverConfig } from '../interfaces/index.js';
import { PluginsExplorerService } from '../services/plugins-explorer.service.js';
import { ApolloBaseDriver } from './apollo-base.driver.js';

/**
* @publicApi
Expand All @@ -35,7 +35,7 @@ export class ApolloFederationDriver extends ApolloBaseDriver {
);

if (options.definitions && options.definitions.path) {
const { printSubgraphSchema } = loadPackage(
const { printSubgraphSchema } = await loadPackage(
'@apollo/subgraph',
'ApolloFederation',
() => require('@apollo/subgraph'),
Expand All @@ -50,7 +50,7 @@ export class ApolloFederationDriver extends ApolloBaseDriver {

if (options.installSubscriptionHandlers || options.subscriptions) {
const subscriptionsOptions: SubscriptionConfig =
options.subscriptions || { 'subscriptions-transport-ws': {} };
options.subscriptions || { 'graphql-ws': {} };
this._subscriptionService = new GqlSubscriptionService(
{
schema: options.schema!,
Expand Down
10 changes: 5 additions & 5 deletions packages/apollo/lib/drivers/apollo-gateway.driver.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common';
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { loadPackage } from '@nestjs/common/utils/load-package.util.js';
import { ModulesContainer } from '@nestjs/core';
import { extend } from '@nestjs/graphql';
import { GraphQLSchema } from 'graphql';
import { ApolloGatewayDriverConfig } from '../interfaces';
import { PluginsExplorerService } from '../services/plugins-explorer.service';
import { ApolloBaseDriver } from './apollo-base.driver';
import { ApolloGatewayDriverConfig } from '../interfaces/index.js';
import { PluginsExplorerService } from '../services/plugins-explorer.service.js';
import { ApolloBaseDriver } from './apollo-base.driver.js';

/**
* @publicApi
Expand All @@ -26,7 +26,7 @@ export class ApolloGatewayDriver extends ApolloBaseDriver<ApolloGatewayDriverCon
this.pluginsExplorerService.explore(options),
);

const { ApolloGateway } = loadPackage(
const { ApolloGateway } = await loadPackage(
'@apollo/gateway',
'ApolloGateway',
() => require('@apollo/gateway'),
Expand Down
8 changes: 4 additions & 4 deletions packages/apollo/lib/drivers/apollo.driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
SubscriptionConfig,
} from '@nestjs/graphql';
import { printSchema } from 'graphql';
import { ApolloDriverConfig } from '../interfaces';
import { PluginsExplorerService } from '../services/plugins-explorer.service';
import { ApolloBaseDriver } from './apollo-base.driver';
import { ApolloDriverConfig } from '../interfaces/index.js';
import { PluginsExplorerService } from '../services/plugins-explorer.service.js';
import { ApolloBaseDriver } from './apollo-base.driver.js';

/**
* @publicApi
Expand Down Expand Up @@ -40,7 +40,7 @@ export class ApolloDriver extends ApolloBaseDriver {

if (options.installSubscriptionHandlers || options.subscriptions) {
const subscriptionsOptions: SubscriptionConfig =
options.subscriptions || { 'subscriptions-transport-ws': {} };
options.subscriptions || { 'graphql-ws': {} };
this._subscriptionService = new GqlSubscriptionService(
{
schema: options.schema!,
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo/lib/drivers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './apollo-federation.driver';
export * from './apollo-gateway.driver';
export * from './apollo.driver';
export * from './apollo-federation.driver.js';
export * from './apollo-gateway.driver.js';
export * from './apollo.driver.js';
8 changes: 4 additions & 4 deletions packages/apollo/lib/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './authentication.error';
export * from './forbidden.error';
export * from './user-input.error';
export * from './validation.error';
export * from './authentication.error.js';
export * from './forbidden.error.js';
export * from './user-input.error.js';
export * from './validation.error.js';
2 changes: 1 addition & 1 deletion packages/apollo/lib/graphiql/graphiql-html.factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphiQLOptions } from './interfaces/graphiql-options.interface';
import { GraphiQLOptions } from './interfaces/graphiql-options.interface.js';

export class GraphiQLHTMLFactory {
create(options: GraphiQLOptions): string {
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo/lib/graphiql/graphiql-playground.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloServerPlugin } from '@apollo/server';
import { GraphiQLHTMLFactory } from './graphiql-html.factory';
import { GraphiQLOptions } from './interfaces/graphiql-options.interface';
import { GraphiQLHTMLFactory } from './graphiql-html.factory.js';
import { GraphiQLOptions } from './interfaces/graphiql-options.interface.js';

export class GraphiQLPlaygroundPlugin implements ApolloServerPlugin {
private readonly graphiqlHTMLFactory = new GraphiQLHTMLFactory();
Expand Down
12 changes: 6 additions & 6 deletions packages/apollo/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './decorators';
export * from './drivers';
export * from './errors';
export * from './interfaces';
export * from './utils';
export * from './services';
export * from './decorators/index.js';
export * from './drivers/index.js';
export * from './errors/index.js';
export * from './interfaces/index.js';
export * from './utils/index.js';
export * from './services/index.js';
12 changes: 6 additions & 6 deletions packages/apollo/lib/interfaces/apollo-driver-config.interface.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ApolloServerOptionsWithTypeDefs } from '@apollo/server';
import { ApolloServerPluginLandingPageGraphQLPlaygroundOptions } from '@apollo/server-plugin-landing-page-graphql-playground';
import {
GqlModuleAsyncOptions,
GqlModuleOptions,
GqlOptionsFactory,
SubscriptionConfig,
} from '@nestjs/graphql';
import { GraphiQLOptions } from '../graphiql/interfaces/graphiql-options.interface';
import { GraphiQLOptions } from '../graphiql/interfaces/graphiql-options.interface.js';

/**
* @publicApi
Expand All @@ -29,7 +28,7 @@ export interface ApolloDriverConfig
ServerRegistration,
GqlModuleOptions {
/**
* If enabled, "subscriptions-transport-ws" will be automatically registered.
* If enabled, graphql-ws will be automatically registered.
*/
installSubscriptionHandlers?: boolean;

Expand All @@ -39,13 +38,14 @@ export interface ApolloDriverConfig
subscriptions?: SubscriptionConfig;

/**
* GraphQL playground options.
* The built-in playground is deprecated and will be replaced with GraphiQL in the future.
* Deprecated boolean alias for GraphiQL.
* Set to `true` to enable GraphiQL, or `false` to disable the landing page.
*/
playground?: boolean | ApolloServerPluginLandingPageGraphQLPlaygroundOptions;
playground?: boolean;

/**
* GraphiQL options, or a boolean to enable GraphiQL with default options.
* GraphiQL is enabled by default in non-production when neither landing page option is configured.
*/
graphiql?: boolean | GraphiQLOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ApolloDriverAsyncConfig,
ApolloDriverConfig,
ApolloDriverConfigFactory,
} from './apollo-driver-config.interface';
} from './apollo-driver-config.interface.js';

export type ApolloFederationDriverConfig = ApolloDriverConfig;
export type ApolloFederationDriverConfigFactory = ApolloDriverConfigFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
GraphQLDriver,
} from '@nestjs/graphql';
import { GraphQLSchema } from 'graphql';
import { ApolloDriverConfig } from './apollo-driver-config.interface';
import { ApolloDriverConfig } from './apollo-driver-config.interface.js';

/**
* @publicApi
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo/lib/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './apollo-driver-config.interface';
export * from './apollo-federation-driver-config.interface';
export * from './apollo-gateway-driver-config.interface';
export * from './apollo-driver-config.interface.js';
export * from './apollo-federation-driver-config.interface.js';
export * from './apollo-gateway-driver-config.interface.js';
2 changes: 1 addition & 1 deletion packages/apollo/lib/services/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './plugins-explorer.service';
export * from './plugins-explorer.service.js';
6 changes: 3 additions & 3 deletions packages/apollo/lib/services/plugins-explorer.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { ModulesContainer } from '@nestjs/core/injector/modules-container';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';
import { ModulesContainer } from '@nestjs/core/injector/modules-container.js';
import { BaseExplorerService, GqlModuleOptions } from '@nestjs/graphql';
import { PLUGIN_METADATA } from '../constants';
import { PLUGIN_METADATA } from '../constants/index.js';

export class PluginsExplorerService extends BaseExplorerService {
constructor(private readonly modulesContainer: ModulesContainer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo/lib/utils/get-apollo-server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApolloServer, type BaseContext } from '@apollo/server';
import { INestApplicationContext } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver } from '..';
import { ApolloDriver } from '../index.js';

type GetApolloServer = (
app: INestApplicationContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './get-apollo-server';
export * from './get-apollo-server.js';
Loading