File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424 "node" : " >=6"
2525 },
2626 "dependencies" : {
27+ "@apollographql/apollo-tools" : " ^0.2.0" ,
2728 "@apollographql/apollo-upload-server" : " ^5.0.3" ,
2829 "@apollographql/graphql-playground-html" : " ^1.6.4" ,
2930 "@types/ws" : " ^6.0.0" ,
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ import {
5252} from './requestPipeline' ;
5353
5454import { Headers } from 'apollo-server-env' ;
55+ import { buildServiceDefinition } from '../../../../apollo-tooling/packages/apollo-tools/lib' ;
5556
5657const NoIntrospection = ( context : ValidationContext ) => ( {
5758 Field ( node : FieldDefinitionNode ) {
@@ -117,6 +118,7 @@ export class ApolloServerBase {
117118 resolvers,
118119 schema,
119120 schemaDirectives,
121+ modules,
120122 typeDefs,
121123 introspection,
122124 mocks,
@@ -215,10 +217,16 @@ export class ApolloServerBase {
215217
216218 if ( schema ) {
217219 this . schema = schema ;
220+ } else if ( modules ) {
221+ const { schema, errors } = buildServiceDefinition ( modules ) ;
222+ if ( errors && errors . length > 0 ) {
223+ throw new Error ( errors . map ( error => error . message ) . join ( '\n\n' ) ) ;
224+ }
225+ this . schema = schema ! ;
218226 } else {
219227 if ( ! typeDefs ) {
220228 throw Error (
221- 'Apollo Server requires either an existing schema or typeDefs' ,
229+ 'Apollo Server requires either an existing schema, modules or typeDefs' ,
222230 ) ;
223231 }
224232
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ import {
1717import { CacheControlExtensionOptions } from 'apollo-cache-control' ;
1818import { ApolloServerPlugin } from 'apollo-server-plugin-base' ;
1919
20+ import { GraphQLSchemaModule } from '@apollographql/apollo-tools' ;
21+ export { GraphQLSchemaModule } ;
22+
2023export { KeyValueCache } from 'apollo-server-caching' ;
2124
2225export type Context < T = any > = T ;
@@ -54,6 +57,7 @@ export interface Config
5457 | 'dataSources'
5558 | 'cache'
5659 > {
60+ modules ?: GraphQLSchemaModule [ ] ;
5761 typeDefs ?: DocumentNode | Array < DocumentNode > ;
5862 resolvers ?: IResolvers ;
5963 schema ?: GraphQLSchema ;
Original file line number Diff line number Diff line change 77 GraphQLOptions ,
88 GraphQLExtension ,
99 Config ,
10+ GraphQLSchemaModule ,
1011 // Errors
1112 ApolloError ,
1213 toApolloError ,
Original file line number Diff line number Diff line change 1313 "engines" : {
1414 "node" : " >=6.0"
1515 },
16+ "dependencies" : {
17+ "@apollographql/apollo-tools" : " ^0.2.0"
18+ },
1619 "devDependencies" : {
1720 "apollo-server-core" : " file:../apollo-server-core" ,
1821 "apollo-server-env" : " file:../apollo-server-env"
You can’t perform that action at this time.
0 commit comments