File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,15 @@ public struct GraphQLRequest: Equatable, Codable {
2727 /// - Returns: True if request is a subscription, false if it is an atomic operation (like
2828 /// `query` or `mutation`)
2929 public func isSubscription( ) throws -> Bool {
30+ return try operationType ( ) == . subscription
31+ }
32+
33+ /// The type of operation perfomed by the request.
34+ /// This operation performs an entire AST parse on the GraphQL request, so consider
35+ /// performance when calling multiple times.
36+ ///
37+ /// - Returns: The operation type performed by the request
38+ public func operationType( ) throws -> OperationType {
3039 let documentAST = try GraphQL . parse (
3140 instrumentation: NoOpInstrumentation,
3241 source: Source ( body: query, name: " GraphQL request " )
@@ -35,6 +44,6 @@ public struct GraphQLRequest: Equatable, Codable {
3544 guard let operationType = firstOperation? . operation else {
3645 throw GraphQLError ( message: " GraphQL operation type could not be determined " )
3746 }
38- return operationType == . subscription
47+ return operationType
3948 }
4049}
You can’t perform that action at this time.
0 commit comments