8
8
GraphQLObjectType , GraphQLSchema , GraphQLString )
9
9
10
10
11
- def test_tracing_result (mocker ):
11
+ def test_tracing (mocker ):
12
12
time_mock = mocker .patch ('time.time' )
13
13
time_mock .side_effect = range (0 , 10000 )
14
14
@@ -85,8 +85,17 @@ def __init__(self, uid, width, height):
85
85
{
86
86
feed {
87
87
id
88
- title
89
- }
88
+ ...articleFields
89
+ author {
90
+ id
91
+ name
92
+ }
93
+ },
94
+ }
95
+ fragment articleFields on Article {
96
+ title,
97
+ body,
98
+ hidden,
90
99
}
91
100
'''
92
101
@@ -99,62 +108,45 @@ def __init__(self, uid, width, height):
99
108
"feed" : [
100
109
{
101
110
"id" : "1" ,
102
- "title" : "My Article 1"
111
+ "title" : "My Article 1" ,
112
+ "body" : "This is a post" ,
113
+ "author" : {
114
+ "id" : "123" ,
115
+ "name" : "John Smith"
116
+ }
103
117
},
104
118
{
105
119
"id" : "2" ,
106
- "title" : "My Article 2"
120
+ "title" : "My Article 2" ,
121
+ "body" : "This is a post" ,
122
+ "author" : {
123
+ "id" : "123" ,
124
+ "name" : "John Smith"
125
+ }
107
126
},
108
127
],
109
128
}
110
129
111
130
assert result .extensions ['tracing' ] == {
112
131
'version' : 1 ,
113
132
'startTime' : time .strftime (TracingMiddleware .DATETIME_FORMAT , time .gmtime (0 )),
114
- 'endTime' : time .strftime (TracingMiddleware .DATETIME_FORMAT , time .gmtime (16 )),
115
- 'duration' : 16000 ,
133
+ 'endTime' : time .strftime (TracingMiddleware .DATETIME_FORMAT , time .gmtime (40 )),
134
+ 'duration' : 40000 ,
116
135
'execution' : {
117
136
'resolvers' : [
118
- {
119
- 'path' : ['feed' ],
120
- 'parentType' : 'Query' ,
121
- 'fieldName' : 'feed' ,
122
- 'returnType' : '[Article]' ,
123
- 'startOffset' : 3000 ,
124
- 'duration' : 1000
125
- },
126
- {
127
- 'path' : ['feed' , 0 , 'id' ],
128
- 'parentType' : 'Article' ,
129
- 'fieldName' : 'id' ,
130
- 'returnType' : 'String!' ,
131
- 'startOffset' : 6000 ,
132
- 'duration' : 1000
133
- },
134
- {
135
- 'path' : ['feed' , 0 , 'title' ],
136
- 'parentType' : 'Article' ,
137
- 'fieldName' : 'title' ,
138
- 'returnType' : 'String' ,
139
- 'startOffset' : 9000 ,
140
- 'duration' : 1000
141
- },
142
- {
143
- 'path' : ['feed' , 1 , 'id' ],
144
- 'parentType' : 'Article' ,
145
- 'fieldName' : 'id' ,
146
- 'returnType' : 'String!' ,
147
- 'startOffset' : 12000 ,
148
- 'duration' : 1000
149
- },
150
- {
151
- 'path' : ['feed' , 1 , 'title' ],
152
- 'parentType' : 'Article' ,
153
- 'fieldName' : 'title' ,
154
- 'returnType' : 'String' ,
155
- 'startOffset' : 15000 ,
156
- 'duration' : 1000
157
- }
137
+ {'path' : ['feed' ], 'parentType' : 'Query' , 'fieldName' : 'feed' , 'returnType' : '[Article]' , 'startOffset' : 3000 , 'duration' : 1000 },
138
+ {'path' : ['feed' , 0 , 'id' ], 'parentType' : 'Article' , 'fieldName' : 'id' , 'returnType' : 'String!' , 'startOffset' : 6000 , 'duration' : 1000 },
139
+ {'path' : ['feed' , 0 , 'title' ], 'parentType' : 'Article' , 'fieldName' : 'title' , 'returnType' : 'String' , 'startOffset' : 9000 , 'duration' : 1000 },
140
+ {'path' : ['feed' , 0 , 'body' ], 'parentType' : 'Article' , 'fieldName' : 'body' , 'returnType' : 'String' , 'startOffset' : 12000 , 'duration' : 1000 },
141
+ {'path' : ['feed' , 0 , 'author' ], 'parentType' : 'Article' , 'fieldName' : 'author' , 'returnType' : 'Author' , 'startOffset' : 15000 , 'duration' : 1000 },
142
+ {'path' : ['feed' , 1 , 'id' ], 'parentType' : 'Article' , 'fieldName' : 'id' , 'returnType' : 'String!' , 'startOffset' : 18000 , 'duration' : 1000 },
143
+ {'path' : ['feed' , 1 , 'title' ], 'parentType' : 'Article' , 'fieldName' : 'title' , 'returnType' : 'String' , 'startOffset' : 21000 , 'duration' : 1000 },
144
+ {'path' : ['feed' , 1 , 'body' ], 'parentType' : 'Article' , 'fieldName' : 'body' , 'returnType' : 'String' , 'startOffset' : 24000 , 'duration' : 1000 },
145
+ {'path' : ['feed' , 1 , 'author' ], 'parentType' : 'Article' , 'fieldName' : 'author' , 'returnType' : 'Author' , 'startOffset' : 27000 , 'duration' : 1000 },
146
+ {'path' : ['feed' , 0 , 'author' , 'id' ], 'parentType' : 'Author' , 'fieldName' : 'id' , 'returnType' : 'String' , 'startOffset' : 30000 , 'duration' : 1000 },
147
+ {'path' : ['feed' , 0 , 'author' , 'name' ], 'parentType' : 'Author' , 'fieldName' : 'name' , 'returnType' : 'String' , 'startOffset' : 33000 , 'duration' : 1000 },
148
+ {'path' : ['feed' , 1 , 'author' , 'id' ], 'parentType' : 'Author' , 'fieldName' : 'id' , 'returnType' : 'String' , 'startOffset' : 36000 , 'duration' : 1000 },
149
+ {'path' : ['feed' , 1 , 'author' , 'name' ], 'parentType' : 'Author' , 'fieldName' : 'name' , 'returnType' : 'String' , 'startOffset' : 39000 , 'duration' : 1000 }
158
150
]
159
151
}
160
152
}
0 commit comments