Skip to content

Commit 67a89c6

Browse files
committed
Use same parameter names as in graphql/graphql_sync
Replicates graphql/graphql-relay-js@db5c587
1 parent ffdaf3f commit 67a89c6

9 files changed

+92
-88
lines changed

tests/connection/test_connection.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class User(NamedTuple):
9696

9797
def describe_connection_definition():
9898
def includes_connection_and_edge_fields():
99-
query = """
99+
source = """
100100
query FriendsQuery {
101101
user {
102102
friends(first: 2) {
@@ -111,7 +111,7 @@ def includes_connection_and_edge_fields():
111111
}
112112
}
113113
"""
114-
assert graphql_sync(schema, query) == (
114+
assert graphql_sync(schema, source) == (
115115
{
116116
"user": {
117117
"friends": {
@@ -127,7 +127,7 @@ def includes_connection_and_edge_fields():
127127
)
128128

129129
def works_with_forward_connection_args():
130-
query = """
130+
source = """
131131
query FriendsQuery {
132132
user {
133133
friendsForward(first: 2) {
@@ -140,7 +140,7 @@ def works_with_forward_connection_args():
140140
}
141141
}
142142
"""
143-
assert graphql_sync(schema, query) == (
143+
assert graphql_sync(schema, source) == (
144144
{
145145
"user": {
146146
"friendsForward": {
@@ -152,7 +152,7 @@ def works_with_forward_connection_args():
152152
)
153153

154154
def works_with_backward_connection_args():
155-
query = """
155+
source = """
156156
query FriendsQuery {
157157
user {
158158
friendsBackward(last: 2) {
@@ -165,7 +165,7 @@ def works_with_backward_connection_args():
165165
}
166166
}
167167
"""
168-
assert graphql_sync(schema, query) == (
168+
assert graphql_sync(schema, source) == (
169169
{
170170
"user": {
171171
"friendsBackward": {

tests/mutation/test_mutation.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ async def mutate_and_get_one_as_payload_async(_info, **_input):
9696

9797
def describe_mutation_with_client_mutation_id():
9898
def requires_an_argument():
99-
query = """
99+
source = """
100100
mutation M {
101101
simpleMutation {
102102
result
103103
}
104104
}
105105
"""
106-
assert graphql_sync(schema, query) == (
106+
assert graphql_sync(schema, source) == (
107107
None,
108108
[
109109
{
@@ -116,21 +116,21 @@ def requires_an_argument():
116116
)
117117

118118
def returns_the_same_client_mutation_id():
119-
query = """
119+
source = """
120120
mutation M {
121121
simpleMutation(input: {clientMutationId: "abc"}) {
122122
result
123123
clientMutationId
124124
}
125125
}
126126
"""
127-
assert graphql_sync(schema, query) == (
127+
assert graphql_sync(schema, source) == (
128128
{"simpleMutation": {"result": 1, "clientMutationId": "abc"}},
129129
None,
130130
)
131131

132132
def supports_thunks_as_input_and_output_fields():
133-
query = """
133+
source = """
134134
mutation M {
135135
simpleMutationWithThunkFields(
136136
input: {inputData: 1234, clientMutationId: "abc"}) {
@@ -139,7 +139,7 @@ def supports_thunks_as_input_and_output_fields():
139139
}
140140
}
141141
"""
142-
assert graphql_sync(schema, query) == (
142+
assert graphql_sync(schema, source) == (
143143
{
144144
"simpleMutationWithThunkFields": {
145145
"result": 1234,
@@ -151,50 +151,50 @@ def supports_thunks_as_input_and_output_fields():
151151

152152
@mark.asyncio
153153
async def supports_async_mutations():
154-
query = """
154+
source = """
155155
mutation M {
156156
simpleAsyncMutation(input: {clientMutationId: "abc"}) {
157157
result
158158
clientMutationId
159159
}
160160
}
161161
"""
162-
assert await graphql(schema, query) == (
162+
assert await graphql(schema, source) == (
163163
{"simpleAsyncMutation": {"result": 1, "clientMutationId": "abc"}},
164164
None,
165165
)
166166

167167
def can_access_root_value():
168-
query = """
168+
source = """
169169
mutation M {
170170
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
171171
result
172172
clientMutationId
173173
}
174174
}
175175
"""
176-
assert graphql_sync(schema, query, root_value=Result(1)) == (
176+
assert graphql_sync(schema, source, root_value=Result(1)) == (
177177
{"simpleRootValueMutation": {"result": 1, "clientMutationId": "abc"}},
178178
None,
179179
)
180180

181181
def supports_mutations_returning_null():
182-
query = """
182+
source = """
183183
mutation M {
184184
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
185185
result
186186
clientMutationId
187187
}
188188
}
189189
"""
190-
assert graphql_sync(schema, query, root_value=None) == (
190+
assert graphql_sync(schema, source, root_value=None) == (
191191
{"simpleRootValueMutation": {"result": None, "clientMutationId": "abc"}},
192192
None,
193193
)
194194

195195
def describe_introspection():
196196
def contains_correct_input():
197-
query = """
197+
source = """
198198
{
199199
__type(name: "SimpleMutationInput") {
200200
name
@@ -209,7 +209,7 @@ def contains_correct_input():
209209
}
210210
}
211211
"""
212-
assert graphql_sync(schema, query) == (
212+
assert graphql_sync(schema, source) == (
213213
{
214214
"__type": {
215215
"name": "SimpleMutationInput",
@@ -226,7 +226,7 @@ def contains_correct_input():
226226
)
227227

228228
def contains_correct_payload():
229-
query = """
229+
source = """
230230
{
231231
__type(name: "SimpleMutationPayload") {
232232
name
@@ -241,7 +241,7 @@ def contains_correct_payload():
241241
}
242242
}
243243
"""
244-
assert graphql_sync(schema, query) == (
244+
assert graphql_sync(schema, source) == (
245245
{
246246
"__type": {
247247
"name": "SimpleMutationPayload",
@@ -262,7 +262,7 @@ def contains_correct_payload():
262262
)
263263

264264
def contains_correct_field():
265-
query = """
265+
source = """
266266
{
267267
__schema {
268268
mutationType {
@@ -288,7 +288,7 @@ def contains_correct_field():
288288
}
289289
}
290290
"""
291-
assert graphql_sync(schema, query) == (
291+
assert graphql_sync(schema, source) == (
292292
{
293293
"__schema": {
294294
"mutationType": {
@@ -403,7 +403,7 @@ def contains_correct_field():
403403
)
404404

405405
def contains_correct_descriptions():
406-
query = """
406+
source = """
407407
{
408408
__schema {
409409
mutationType {
@@ -415,7 +415,7 @@ def contains_correct_descriptions():
415415
}
416416
}
417417
"""
418-
assert graphql_sync(schema, query) == (
418+
assert graphql_sync(schema, source) == (
419419
{
420420
"__schema": {
421421
"mutationType": {
@@ -442,7 +442,7 @@ def contains_correct_descriptions():
442442
)
443443

444444
def contains_correct_deprecation_reason():
445-
query = """
445+
source = """
446446
{
447447
__schema {
448448
mutationType {
@@ -455,7 +455,7 @@ def contains_correct_deprecation_reason():
455455
}
456456
}
457457
"""
458-
assert graphql_sync(schema, query) == (
458+
assert graphql_sync(schema, source) == (
459459
{
460460
"__schema": {
461461
"mutationType": {

tests/node/test_global.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ def get_node_type(
130130

131131
def describe_global_id_fields():
132132
def gives_different_ids(schema):
133-
query = """
133+
source = """
134134
{
135135
allObjects {
136136
id
137137
}
138138
}
139139
"""
140-
assert graphql_sync(schema, query) == (
140+
assert graphql_sync(schema, source) == (
141141
{
142142
"allObjects": [
143143
{"id": "VXNlcjox"},
@@ -152,7 +152,7 @@ def gives_different_ids(schema):
152152
)
153153

154154
def refetches_the_ids(schema):
155-
query = """
155+
source = """
156156
{
157157
user: node(id: "VXNlcjox") {
158158
id
@@ -174,7 +174,7 @@ def refetches_the_ids(schema):
174174
}
175175
}
176176
"""
177-
assert graphql_sync(schema, query) == (
177+
assert graphql_sync(schema, source) == (
178178
{
179179
"user": {"id": "VXNlcjox", "name": "John Doe"},
180180
"photo": {"id": "UGhvdG86MQ==", "width": 300},

0 commit comments

Comments
 (0)