@@ -3,13 +3,14 @@ import * as GraphQLHTTP from 'express-graphql';
3
3
import * as DataLoader from 'dataloader' ;
4
4
import { GraphQLSchema , GraphQLObjectType } from 'graphql' ;
5
5
import { Container as container , ObjectType } from 'typedi' ;
6
+ import { Repository , getCustomRepository , getRepository } from 'typeorm' ;
6
7
7
8
import { GraphQLContext , GraphQLContextDataLoader } from './GraphQLContext' ;
8
9
import { MetadataArgsStorage } from './MetadataArgsStorage' ;
9
10
import { importClassesFromDirectories } from './importClassesFromDirectories' ;
10
11
import { handlingErrors , getErrorCode , getErrorMessage } from './graphql-error-handling' ;
11
12
import { ensureInputOrder } from './dataloader' ;
12
- import { Repository , getCustomRepository , getRepository } from 'typeorm ' ;
13
+ import { getFromContainer } from './container ' ;
13
14
14
15
// -------------------------------------------------------------------------
15
16
// Main exports
@@ -22,6 +23,7 @@ export * from './AbstractGraphQLHooks';
22
23
export * from './AbstractGraphQLQuery' ;
23
24
export * from './GraphQLContext' ;
24
25
export * from './graphql-error-handling' ;
26
+ export * from './container' ;
25
27
26
28
// -------------------------------------------------------------------------
27
29
// Main Functions
@@ -168,8 +170,8 @@ export function createSchema(options: GraphQLSchemaOptions): GraphQLSchema {
168
170
}
169
171
170
172
const queries = { } ;
171
- queryClasses . forEach ( queryClass => {
172
- queries [ createQueryName ( queryClass . name ) ] = new queryClass ( ) ;
173
+ getMetadataArgsStorage ( ) . queries . forEach ( queryMetdadata => {
174
+ queries [ createQueryName ( queryMetdadata . name ) ] = getFromContainer ( queryMetdadata . target ) ;
173
175
} ) ;
174
176
175
177
const RootQuery = new GraphQLObjectType ( {
@@ -186,8 +188,8 @@ export function createSchema(options: GraphQLSchemaOptions): GraphQLSchema {
186
188
}
187
189
188
190
const mutations = { } ;
189
- mutationClasses . forEach ( mutationClass => {
190
- mutations [ createMutationName ( mutationClass . name ) ] = new mutationClass ( ) ;
191
+ getMetadataArgsStorage ( ) . mutations . forEach ( mutationMetdadata => {
192
+ mutations [ createMutationName ( mutationMetdadata . name ) ] = getFromContainer ( mutationMetdadata . target ) ;
191
193
} ) ;
192
194
193
195
const RootMutation : GraphQLObjectType = new GraphQLObjectType ( {
0 commit comments