Skip to content

Commit 50fcb9a

Browse files
lukaslueckealanpoulain
authored andcommitted
Return mutation result as entity object (#2612)
* Make clientMutationId nullable * Return mutation result as entity object Fixes #2605 * Change normalization context for test * Fix normalization and delete * Fix unit tests * Use a new type for the wrapped object only when normalization context is used for the mutation
1 parent 3bc6be5 commit 50fcb9a

File tree

9 files changed

+344
-148
lines changed

9 files changed

+344
-148
lines changed

features/graphql/authorization.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ Feature: Authorization checking
4545
"""
4646
mutation {
4747
createSecuredDummy(input: {owner: "me", title: "Hi", description: "Desc", clientMutationId: "auth"}) {
48-
title
49-
owner
48+
securedDummy {
49+
title
50+
owner
51+
}
5052
}
5153
}
5254
"""

features/graphql/introspection.feature

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,20 @@ Feature: GraphQL introspection support
292292
}
293293
}
294294
}
295+
typeCreatePayloadData: __type(name: "createDummyGroupPayloadData") {
296+
description,
297+
fields {
298+
name
299+
type {
300+
name
301+
kind
302+
ofType {
303+
name
304+
kind
305+
}
306+
}
307+
}
308+
}
295309
}
296310
"""
297311
Then the response status code should be 200
@@ -304,10 +318,72 @@ Feature: GraphQL introspection support
304318
And the JSON node "data.typeCreateInput.inputFields[0].name" should be equal to "bar"
305319
And the JSON node "data.typeCreateInput.inputFields[1].name" should be equal to "baz"
306320
And the JSON node "data.typeCreateInput.inputFields[2].name" should be equal to "clientMutationId"
307-
And the JSON node "data.typeCreatePayload.fields" should have 3 elements
308-
And the JSON node "data.typeCreatePayload.fields[0].name" should be equal to "id"
309-
And the JSON node "data.typeCreatePayload.fields[1].name" should be equal to "bar"
310-
And the JSON node "data.typeCreatePayload.fields[2].name" should be equal to "clientMutationId"
321+
And the JSON node "data.typeCreatePayload.fields" should have 2 elements
322+
And the JSON node "data.typeCreatePayload.fields[0].name" should be equal to "dummyGroup"
323+
And the JSON node "data.typeCreatePayload.fields[0].type.name" should be equal to "createDummyGroupPayloadData"
324+
And the JSON node "data.typeCreatePayload.fields[1].name" should be equal to "clientMutationId"
325+
And the JSON node "data.typeCreatePayloadData.fields" should have 2 elements
326+
And the JSON node "data.typeCreatePayloadData.fields[0].name" should be equal to "id"
327+
And the JSON node "data.typeCreatePayloadData.fields[1].name" should be equal to "bar"
328+
329+
Scenario: Retrieve nested mutation payload data fields
330+
When I send the following GraphQL request:
331+
"""
332+
{
333+
typeCreatePayload: __type(name: "createDummyPropertyPayload") {
334+
description,
335+
fields {
336+
name
337+
type {
338+
name
339+
kind
340+
ofType {
341+
name
342+
kind
343+
}
344+
}
345+
}
346+
}
347+
typeCreatePayloadData: __type(name: "createDummyPropertyPayloadData") {
348+
description,
349+
fields {
350+
name
351+
type {
352+
name
353+
kind
354+
ofType {
355+
name
356+
kind
357+
}
358+
}
359+
}
360+
}
361+
typeCreateNestedPayload: __type(name: "createDummyGroupNestedPayload") {
362+
description,
363+
fields {
364+
name
365+
type {
366+
name
367+
kind
368+
ofType {
369+
name
370+
kind
371+
}
372+
}
373+
}
374+
}
375+
}
376+
"""
377+
Then the response status code should be 200
378+
And the response should be in JSON
379+
And the header "Content-Type" should be equal to "application/json"
380+
And the JSON node "data.typeCreatePayload.fields" should have 2 elements
381+
And the JSON node "data.typeCreatePayload.fields[0].name" should be equal to "dummyProperty"
382+
And the JSON node "data.typeCreatePayload.fields[0].type.name" should be equal to "createDummyPropertyPayloadData"
383+
And the JSON node "data.typeCreatePayload.fields[1].name" should be equal to "clientMutationId"
384+
And the JSON node "data.typeCreatePayloadData.fields[3].name" should be equal to "group"
385+
And the JSON node "data.typeCreatePayloadData.fields[3].type.name" should be equal to "createDummyGroupNestedPayload"
386+
And the JSON node "data.typeCreateNestedPayload.fields[0].name" should be equal to "id"
311387

312388
Scenario: Retrieve an item through a GraphQL query
313389
Given there are 4 dummy objects with relatedDummy

0 commit comments

Comments
 (0)