Skip to content

Commit e6c8205

Browse files
authored
Merge pull request #21 from kimdv/master
Added missing context as parameter to Schema.execute
2 parents af1f7c2 + ee88ea9 commit e6c8205

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Sources/Graphiti/Schema/Schema.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,46 @@ public struct Schema<Root, Context, EventLoop: EventLoopGroup> {
550550
operationName: operationName
551551
)
552552
}
553+
554+
public func execute(
555+
request: String,
556+
context: Context,
557+
eventLoopGroup: EventLoopGroup,
558+
variables: [String: Map] = [:],
559+
operationName: String? = nil
560+
) throws -> EventLoopFuture<Map> {
561+
guard Root.self is Void.Type else {
562+
throw GraphQLError(
563+
message: "Root value is required."
564+
)
565+
}
566+
567+
return try graphql(
568+
schema: schema,
569+
request: request,
570+
context: context,
571+
eventLoopGroup: eventLoopGroup,
572+
variableValues: variables,
573+
operationName: operationName
574+
)
575+
}
576+
577+
public func execute(
578+
request: String,
579+
rootValue: Root,
580+
context: Context,
581+
worker: EventLoopGroup,
582+
variables: [String: Map] = [:],
583+
operationName: String? = nil
584+
) throws -> EventLoopFuture<Map> {
585+
return try graphql(
586+
schema: schema,
587+
request: request,
588+
rootValue: rootValue,
589+
context: context,
590+
eventLoopGroup: worker,
591+
variableValues: variables,
592+
operationName: operationName
593+
)
594+
}
553595
}

0 commit comments

Comments
 (0)