Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(graphql): expose complete options #3165

Merged

Conversation

mattia-lau
Copy link
Contributor

@mattia-lau mattia-lau commented Feb 27, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

complete options is not expose

Issue Number: 3164

What is the new behavior?

expose complete options

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

alternative approach to integrate ApolloServer and NestJS(createApplicationContext), without making any big refactoring in current codebase

import { ApolloServer } from '@apollo/server';
import {
  LambdaHandler,
  handlers,
  startServerAndCreateLambdaHandler,
} from '@as-integrations/aws-lambda';
import { ApolloFederationDriver, PluginsExplorerService } from '@nestjs/apollo';
import { ModulesContainer, NestFactory } from '@nestjs/core';
import { GraphQLModule, extend } from '@nestjs/graphql';
import { AppModule } from './app.module';

const requestHandler = handlers.createAPIGatewayProxyEventV2RequestHandler();

let serverless: LambdaHandler<typeof requestHandler>;

const app = await NestFactory.createApplicationContext(AppModule, {
  logger: ['error'],
});

await app.init();

const  { completeOptions } = app.get(GraphQLModule);

const options = extend(completeOptions, {
  plugins: new PluginsExplorerService(moduleContainer).explore(
    completeOptions
  ),
});

const server = new ApolloServer(options);

const handler = startServerAndCreateLambdaHandler(server, requestHandler, {});

@mattia-lau
Copy link
Contributor Author

@kamilmysliwiec

@kamilmysliwiec kamilmysliwiec merged commit 5f9b5d8 into nestjs:master Oct 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants