File tree 1 file changed +10
-1
lines changed
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 {
27
27
/// - Returns: True if request is a subscription, false if it is an atomic operation (like
28
28
/// `query` or `mutation`)
29
29
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 {
30
39
let documentAST = try GraphQL . parse (
31
40
instrumentation: NoOpInstrumentation,
32
41
source: Source ( body: query, name: " GraphQL request " )
@@ -35,6 +44,6 @@ public struct GraphQLRequest: Equatable, Codable {
35
44
guard let operationType = firstOperation? . operation else {
36
45
throw GraphQLError ( message: " GraphQL operation type could not be determined " )
37
46
}
38
- return operationType == . subscription
47
+ return operationType
39
48
}
40
49
}
You can’t perform that action at this time.
0 commit comments