Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/server/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,10 @@ export class ApolloServer<in out TContext extends BaseContext = BaseContext> {
await Promise.all(
this.internals.plugins.map(
async (plugin) =>
plugin.invalidRequestWasReceived?.({ error: maybeError }),
plugin.invalidRequestWasReceived?.({
request: httpGraphQLRequest,
error: maybeError,
}),
),
);
} catch (pluginError) {
Expand Down
9 changes: 8 additions & 1 deletion packages/server/src/externalTypes/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
GraphQLRequestContextWillSendResponse,
GraphQLRequestContextWillSendSubsequentPayload,
} from './requestPipeline.js';
import type { HTTPGraphQLRequest } from './index.js';

export interface GraphQLServerContext {
readonly logger: Logger;
Expand Down Expand Up @@ -76,7 +77,13 @@ export interface ApolloServerPlugin<
* incorrect headers, invalid JSON body, or invalid search params for GET),
* but does not include malformed GraphQL.
*/
invalidRequestWasReceived?({ error }: { error: Error }): Promise<void>;
invalidRequestWasReceived?({
request,
error,
}: {
request: HTTPGraphQLRequest;
error: Error;
}): Promise<void>;
// Called on startup fail. This can occur if the schema fails to load or if a
// `serverWillStart` or `renderLandingPage` hook throws.
startupDidFail?({ error }: { error: Error }): Promise<void>;
Expand Down