8000 test: Use short syntax for queries and mutations · graphql-python/graphql-relay-py@514402e · GitHub
[go: up one dir, main page]

Skip to content

Commit 514402e

Browse files
committed
test: Use short syntax for queries and mutations
Replicates graphql/graphql-relay-js@b8efdbb
1 parent 8d0d568 commit 514402e

File tree

5 files changed

+74
-74
lines changed

5 files changed

+74
-74
lines changed

tests/connection/test_connection.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,20 @@ class User(NamedTuple):
9797
def describe_connection_definition():
9898
def includes_connection_and_edge_fields():
9999
source = """
100-
query FriendsQuery {
101-
user {
102-
friends(first: 2) {
103-
totalCount
104-
edges {
105-
friendshipTime
106-
node {
107-
name
100+
{
101+
user {
102+
friends(first: 2) {
103+
totalCount
104+
edges {
105+
friendshipTime
106+
node {
107+
name
108+
}
108109
}
109110
}
110111
}
111112
}
112-
}
113-
"""
113+
"""
114114
assert graphql_sync(schema, source) == (
115115
{
116116
"user": {
@@ -128,18 +128,18 @@ def includes_connection_and_edge_fields():
128128

129129
def works_with_forward_connection_args():
130130
source = """
131-
query FriendsQuery {
132-
user {
133-
friendsForward(first: 2) {
134-
edges {
135-
node {
136-
name
131+
{
132+
user {
133+
friendsForward(first: 2) {
134+
edges {
135+
node {
136+
name
137+
}
137138
}
138139
}
139140
}
140141
}
141-
}
142-
"""
142+
"""
143143
assert graphql_sync(schema, source) == (
144144
{
145145
"user": {
@@ -153,18 +153,18 @@ def works_with_forward_connection_args():
153153

154154
def works_with_backward_connection_args():
155155
source = """
156-
query FriendsQuery {
157-
user {
158-
friendsBackward(last: 2) {
159-
edges {
160-
node {
161-
name
156+
{
157+
user {
158+
friendsBackward(last: 2) {
159+
edges {
160+
node {
161+
name
162+
}
162163
}
163164
}
164165
}
165166
}
166-
}
167-
"""
167+
"""
168168
assert graphql_sync(schema, source) == (
169169
{
170170
"user": {

tests/mutation/test_mutation.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -97,48 +97,48 @@ async def mutate_and_get_one_as_payload_async(_info, **_input):
9797
def describe_mutation_with_client_mutation_id():
9898
def requires_an_argument():
9999
source = """
100-
mutation M {
101-
simpleMutation {
102-
result
100+
mutation {
101+
simpleMutation {
102+
result
103+
}
103104
}
104-
}
105-
"""
105+
"""
106106
assert graphql_sync(schema, source) == (
107107
None,
108108
[
109109
{
110110
"message": "Field 'simpleMutation' argument 'input'"
111111
" of type 'SimpleMutationInput!' is required,"
112112
" but it was not provided.",
113-
"locations": [(3, 13)],
113+
"locations": [(3, 15)],
114114
}
115115
],
116116
)
117117

118118
def returns_the_same_client_mutation_id():
119119
source = """
120-
mutation M {
121-
simpleMutation(input: {clientMutationId: "abc"}) {
122-
result
123-
clientMutationId
120+
mutation {
121+
simpleMutation(input: {clientMutationId: "abc"}) {
122+
result
123+
clientMutationId
124+
}
124125
}
125-
}
126-
"""
126+
"""
127127
assert graphql_sync(schema, source) == (
128128
{"simpleMutation": {"result": 1, "clientMutationId": "abc"}},
129129
None,
130130
)
131131

132132
def supports_thunks_as_input_and_output_fields():
133133
source = """
134-
mutation M {
135-
simpleMutationWithThunkFields(
136-
input: {inputData: 1234, clientMutationId: "abc"}) {
137-
result
138-
clientMutationId
134+
mutation {
135+
simpleMutationWithThunkFields(
136+
input: {inputData: 1234, clientMutationId: "abc"}) {
137+
result
138+
clientMutationId
139+
}
139140
}
140-
}
141-
"""
141+
"""
142142
assert graphql_sync(schema, source) == (
143143
{
144144
"simpleMutationWithThunkFields": {
@@ -152,41 +152,41 @@ def supports_thunks_as_input_and_output_fields():
152152
@mark.asyncio
153153
async def supports_async_mutations():
154154
source = """
155-
mutation M {
156-
simpleAsyncMutation(input: {clientMutationId: "abc"}) {
157-
result
158-
clientMutationId
155+
mutation {
156+
simpleAsyncMutation(input: {clientMutationId: "abc"}) {
157+
result
158+
clientMutationId
159+
}
159160
}
160-
}
161-
"""
161+
"""
162162
assert await graphql(schema, source) == (
163163
{"simpleAsyncMutation": {"result": 1, "clientMutationId": "abc"}},
164164
None,
165165
)
166166

167167
def can_access_root_value():
168168
source = """
169-
mutation M {
170-
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
171-
result
172-
clientMutationId
169+
mutation {
170+
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
171+
result
172+
clientMutationId
173+
}
173174
}
174-
}
175-
"""
175+
"""
176176
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():
182182
source = """
183-
mutation M {
184-
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
185-
result
186-
clientMutationId
183+
mutation {
184+
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
185+
result
186+
clientMutationId
187+
}
187188
}
188-
}
189-
"""
189+
"""
190190
assert graphql_sync(schema, source, root_value=None) == (
191191
{"simpleRootValueMutation": {"result": None, "clientMutationId": "abc"}},
192192
None,

tests/test_star_wars_connections.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def describe_star_wars_connections():
77
def fetches_the_first_ship_of_the_rebels():
88
source = """
9-
query RebelsShipsQuery {
9+
{
1010
rebels {
1111
name,
1212
ships(first: 1) {
@@ -30,7 +30,7 @@ def fetches_the_first_ship_of_the_rebels():
3030

3131
def fetches_the_first_two_ships_of_the_rebels_with_a_cursor():
3232
source = """
33-
query MoreRebelShipsQuery {
33+
{
3434
rebels {
3535
name,
3636
ships(first: 2) {
@@ -66,7 +66,7 @@ def fetches_the_first_two_ships_of_the_rebels_with_a_cursor():
6666

6767
def fetches_the_next_three_ships_of_the_rebels_with_a_cursor():
6868
source = """
69-
query EndOfRebelShipsQuery {
69+
{
7070
rebels {
7171
name,
7272
ships(first: 3 after: "YXJyYXljb25uZWN0aW9uOjE=") {
@@ -106,7 +106,7 @@ def fetches_the_next_three_ships_of_the_rebels_with_a_cursor():
106106

107107
def fetches_no_ships_of_the_rebels_at_the_end_of_connection():
108108
source = """
109-
query RebelsQuery {
109+
{
110110
rebels {
111111
name,
112112
ships(first: 3 after: "YXJyYXljb25uZWN0aW9uOjQ=") {
@@ -131,7 +131,7 @@ def fetches_no_ships_of_the_rebels_at_the_end_of_connection():
131131

132132
def identifies_the_end_of_the_list():
133133
source = """
134-
query EndOfRebelShipsQuery {
134+
{
135135
rebels {
136136
name,
137137
originalShips: ships(first: 2) {

tests/test_star_wars_mutations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def describe_star_wars_mutations():
77
def correctly_mutates_dataset():
88
source = """
9-
mutation AddBWingQuery($input: IntroduceShipInput!) {
9+
mutation ($input: IntroduceShipInput!) {
1010
introduceShip(input: $input) {
1111
ship {
1212
id

tests/test_star_wars_object_identification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def describe_star_wars_object_identification():
77
def fetches_the_id_and_name_of_the_rebels():
88
source = """
9-
query RebelsQuery {
9+
{
1010
rebels {
1111
id
1212
name
@@ -21,7 +21,7 @@ def fetches_the_id_and_name_of_the_rebels():
2121

2222
def refetches_the_rebels():
2323
source = """
24-
query RebelsRefetchQuery {
24+
{
2525
node(id: "RmFjdGlvbjox") {
2626
id
2727
... on Faction {
@@ -38,7 +38,7 @@ def refetches_the_rebels():
3838

3939
def fetches_the_id_and_name_of_the_empire():
4040
source = """
41-
query EmpireQuery {
41+
{
4242
empire {
4343
id
4444
name
@@ -51,7 +51,7 @@ def fetches_the_id_and_name_of_the_empire():
5151

5252
def refetches_the_empire():
5353
source = """
54-
query EmpireRefetchQuery {
54+
{
5555
node(id: "RmFjdGlvbjoy") {
5656
id
5757
... on Faction {
@@ -66,7 +66,7 @@ def refetches_the_empire():
6666

6767
def refetches_the_x_wing():
6868
source = """
69-
query XWingRefetchQuery {
69+
{
7070
node(id: "U2hpcDox") {
7171
id
7272
... on Ship {

0 commit comments

Comments
 (0)
0