@@ -2,11 +2,19 @@ import Vapor
2
2
import GraphQL
3
3
import Graphiti
4
4
5
- public typealias ExecutionContext = (
6
- schema: GraphQLSchema ,
7
- rootValue: Any ,
8
- context: Any
9
- )
5
+ public struct ExecutionContext {
6
+ public let schema : GraphQLSchema
7
+ public let rootValue : Any
8
+ public let context : Any
9
+ public let eventLoopGroup : EventLoopGroup
10
+
11
+ public init ( schema: GraphQLSchema , rootValue: Any , context: Any , eventLoopGroup: EventLoopGroup ) {
12
+ self . schema = schema
13
+ self . rootValue = rootValue
14
+ self . context = context
15
+ self . eventLoopGroup = eventLoopGroup
16
+ }
17
+ }
10
18
11
19
/// Provides HTTPGraphQL an execution context to perform per request.
12
20
public typealias ExecutionContextProvider = ( Request ) throws -> ExecutionContext
@@ -33,15 +41,15 @@ public struct HTTPGraphQL: GraphQLService {
33
41
return self . executeIntrospectionQuery ( for: req)
34
42
}
35
43
do {
36
- let ( schema , rootValue , context ) = try self . executionContextProvider ( req)
44
+ let executionContext = try self . executionContextProvider ( req)
37
45
let result = try graphql (
38
- schema: schema,
39
- request: executionRequest. query,
40
- rootValue: rootValue,
41
- context: context,
42
- eventLoopGroup: req ,
43
- variableValues: executionRequest. variables,
44
- operationName: executionRequest. operationName)
46
+ schema: executionContext . schema,
47
+ request: executionRequest. query,
48
+ rootValue: executionContext . rootValue,
49
+ context: executionContext . context,
50
+ eventLoopGroup: executionContext . eventLoopGroup ,
51
+ variableValues: executionRequest. variables,
52
+ operationName: executionRequest. operationName)
45
53
return result
46
54
} catch let e as GraphQLError {
47
55
let graphQLError : [ String : Map ] = [
0 commit comments