@@ -17,16 +17,17 @@ import kotlin.reflect.KType
17
17
import kotlin.reflect.full.starProjectedType
18
18
import kotlin.reflect.jvm.jvmErasure
19
19
20
- class DefaultSchema (
20
+ class DefaultSchema <Context : Any >(
21
+ internal val contextClass : KClass <Context >,
21
22
internal val configuration : SchemaConfiguration ,
22
23
internal val model : SchemaModel
23
- ) : Schema, __Schema by model, LookupSchema {
24
+ ) : Schema<Context> , __Schema by model, LookupSchema<Context> {
24
25
25
26
companion object {
26
27
const val OPERATION_NAME_PARAM = " operationName"
27
28
}
28
29
29
- val requestExecutor : RequestExecutor = ParallelRequestExecutor (this )
30
+ val requestExecutor : RequestExecutor < Context > = ParallelRequestExecutor (this )
30
31
31
32
val requestInterpreter : RequestInterpreter = RequestInterpreter (model)
32
33
@@ -39,7 +40,7 @@ class DefaultSchema(
39
40
DocumentParser ()
40
41
}
41
42
42
- override fun execute (request : String , variables : String? ): String {
43
+ override fun execute (request : String , variables : String? , context : Context ? ): String {
43
44
val parsedVariables = variables
44
45
?.let { VariablesJson .Defined (configuration.objectMapper, variables) }
45
46
? : VariablesJson .Empty ()
@@ -50,7 +51,11 @@ class DefaultSchema(
50
51
throw RequestException (" Must provide any operation" )
51
52
}
52
53
1 -> {
53
- return requestExecutor.execute(requestInterpreter.createExecutionPlan(operations.first()), parsedVariables)
54
+ return requestExecutor.execute(
55
+ plan = requestInterpreter.createExecutionPlan(operations.first()),
56
+ variables = parsedVariables,
57
+ context = context
58
+ )
54
59
}
55
60
else -> {
56
61
if (operations.any { it.name == null }){
@@ -64,7 +69,7 @@ class DefaultSchema(
64
69
val executionPlan = executionPlans[operationName]
65
70
? : throw RequestException (" Must provide an operation name from: ${executionPlans.keys} , found $operationName " )
66
71
67
- return requestExecutor.execute(executionPlan, parsedVariables)
72
+ return requestExecutor.execute(executionPlan, parsedVariables, context )
68
73
}
69
74
}
70
75
}
0 commit comments