File tree Expand file tree Collapse file tree 1 file changed +77
-0
lines changed
Tests/GraphitiTests/DirectiveTests Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ @testable import Graphiti
2
+ import GraphQL
3
+ import NIO
4
+ import XCTest
5
+
6
+ class DirectiveTests : XCTestCase {
7
+ private let api = StarWarsAPI ( )
8
+ private var group = MultiThreadedEventLoopGroup ( numberOfThreads: System . coreCount)
9
+
10
+ deinit {
11
+ try ? self . group. syncShutdownGracefully ( )
12
+ }
13
+
14
+ func testSkip( ) async throws {
15
+ let query = """
16
+ query FetchHeroNameWithSkip($skipName: Boolean!) {
17
+ hero {
18
+ id
19
+ name @skip(if: $skipName)
20
+ }
21
+ }
22
+ """
23
+
24
+ let input : [ String : Map ] = [
25
+ " skipName " : true
26
+ ]
27
+
28
+ let response = try await api. execute (
29
+ request: query,
30
+ context: StarWarsContext ( ) ,
31
+ on: group,
32
+ variables: input
33
+ )
34
+
35
+ let expected = GraphQLResult (
36
+ data: [
37
+ " hero " : [
38
+ " id " : " 2001 "
39
+ ] ,
40
+ ]
41
+ )
42
+
43
+ XCTAssertEqual ( response, expected)
44
+ }
45
+
46
+ func testInclude( ) async throws {
47
+ let query = """
48
+ query FetchHeroNameWithSkip($includeName: Boolean!) {
49
+ hero {
50
+ id
51
+ name @include(if: $includeName)
52
+ }
53
+ }
54
+ """
55
+
56
+ let input : [ String : Map ] = [
57
+ " includeName " : false
58
+ ]
59
+
60
+ let response = try await api. execute (
61
+ request: query,
62
+ context: StarWarsContext ( ) ,
63
+ on: group,
64
+ variables: input
65
+ )
66
+
67
+ let expected = GraphQLResult (
68
+ data: [
69
+ " hero " : [
70
+ " id " : " 2001 "
71
+ ] ,
72
+ ]
73
+ )
74
+
75
+ XCTAssertEqual ( response, expected)
76
+ }
77
+ }
You can’t perform that action at this time.
0 commit comments