-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
208 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
import { ApolloServerBase } from 'apollo-server-core'; | ||
import { GraphQLFederationModule, GraphQLModule } from '..'; | ||
|
||
/** | ||
* Returns the underlying ApolloServer instance for a given application. | ||
* Supports both Apollo federation and regular GraphQL applications. | ||
* @param app Nest application reference | ||
* @returns Apollo Server instance used by the host application | ||
*/ | ||
export function getApolloServer( | ||
app: INestApplicationContext, | ||
): ApolloServerBase { | ||
try { | ||
const graphqlFederationModule = app.get(GraphQLFederationModule); | ||
return graphqlFederationModule.apolloServer; | ||
} catch (error) {} | ||
try { | ||
const graphqlModule = app.get(GraphQLModule); | ||
return graphqlModule.apolloServer; | ||
} catch (error) {} | ||
throw new Error( | ||
'Nest could not find either the GraphQLFederationModule or GraphQLModule. Neither module is registered in the given application.', | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.