5
5
from graphene .contrib .django .utils import DJANGO_FILTER_INSTALLED
6
6
7
7
from ...tests .models import Reporter
8
- from ..plugin import DjangoDebugPlugin
8
+ from ..middleware import DjangoDebugMiddleware
9
+ from ..types import DjangoDebug
10
+
11
+ class context (object ):
12
+ pass
9
13
10
14
# from examples.starwars_django.models import Character
11
15
@@ -25,6 +29,7 @@ class Meta:
25
29
26
30
class Query (graphene .ObjectType ):
27
31
reporter = graphene .Field (ReporterType )
32
+ debug = graphene .Field (DjangoDebug , name = '__debug' )
28
33
29
34
def resolve_reporter (self , * args , ** kwargs ):
30
35
return Reporter .objects .first ()
@@ -51,8 +56,8 @@ def resolve_reporter(self, *args, **kwargs):
51
56
}]
52
57
}
53
58
}
54
- schema = graphene .Schema (query = Query , plugins = [DjangoDebugPlugin ()])
55
- result = schema .execute (query )
59
+ schema = graphene .Schema (query = Query , plugins = [DjangoDebugMiddleware ()])
60
+ result = schema .execute (query , context_value = context () )
56
61
assert not result .errors
57
62
assert result .data == expected
58
63
@@ -70,6 +75,7 @@ class Meta:
70
75
71
76
class Query (graphene .ObjectType ):
72
77
all_reporters = ReporterType .List ()
78
+ debug = graphene .Field (DjangoDebug , name = '__debug' )
73
79
74
80
def resolve_all_reporters (self , * args , ** kwargs ):
75
81
return Reporter .objects .all ()
@@ -98,8 +104,8 @@ def resolve_all_reporters(self, *args, **kwargs):
98
104
}]
99
105
}
100
106
}
101
- schema = graphene .Schema (query = Query , plugins = [DjangoDebugPlugin ()])
102
- result = schema .execute (query )
107
+ schema = graphene .Schema (query = Query , plugins = [DjangoDebugMiddleware ()])
108
+ result = schema .execute (query , context_value = context () )
103
109
assert not result .errors
104
110
assert result .data == expected
105
111
@@ -117,6 +123,7 @@ class Meta:
117
123
118
124
class Query (graphene .ObjectType ):
119
125
all_reporters = DjangoConnectionField (ReporterType )
126
+ debug = graphene .Field (DjangoDebug , name = '__debug' )
120
127
121
128
def resolve_all_reporters (self , * args , ** kwargs ):
122
129
return Reporter .objects .all ()
@@ -146,8 +153,8 @@ def resolve_all_reporters(self, *args, **kwargs):
146
153
}]
147
154
},
148
155
}
149
- schema = graphene .Schema (query = Query , plugins = [DjangoDebugPlugin ()])
150
- result = schema .execute (query )
156
+ schema = graphene .Schema (query = Query , plugins = [DjangoDebugMiddleware ()])
157
+ result = schema .execute (query , context_value = context () )
151
158
assert not result .errors
152
159
assert result .data ['allReporters' ] == expected ['allReporters' ]
153
160
assert 'COUNT' in result .data ['__debug' ]['sql' ][0 ]['rawSql' ]
@@ -172,6 +179,7 @@ class Meta:
172
179
173
180
class Query (graphene .ObjectType ):
174
181
all_reporters = DjangoFilterConnectionField (ReporterType )
182
+ debug = graphene .Field (DjangoDebug , name = '__debug' )
175
183
176
184
def resolve_all_reporters (self , * args , ** kwargs ):
177
185
return Reporter .objects .all ()
@@ -201,8 +209,8 @@ def resolve_all_reporters(self, *args, **kwargs):
201
209
}]
202
210
},
203
211
}
204
- schema = graphene .Schema (query = Query , plugins = [DjangoDebugPlugin ()])
205
- result = schema .execute (query )
212
+ schema = graphene .Schema (query = Query , plugins = [DjangoDebugMiddleware ()])
213
+ result = schema .execute (query , context_value = context () )
206
214
assert not result .errors
207
215
assert result .data ['allReporters' ] == expected ['allReporters' ]
208
216
assert 'COUNT' in result .data ['__debug' ]['sql' ][0 ]['rawSql' ]
0 commit comments