Skip to content

Commit e468d98

Browse files
committed
Merge branch '2.5'
2 parents 8e28a58 + 97d765b commit e468d98

21 files changed

+459
-135
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 2.5.0
4+
5+
* Fix BC-break when using short-syntax notation for `access_control`
6+
* Fix BC-break when no item operations are declared
7+
* GraphQL: Adding serialization group difference condition for `item_query` and `collection_query` types
8+
* JSON Schema: Fix command
9+
10+
## 2.5.0 beta 3
11+
12+
* GraphQL: Use different types (`MyTypeItem` and `MyTypeCollection`) only if serialization groups are different for `item_query` and `collection_query` (#3083)
13+
314
## 2.5.0 beta 2
415

516
* Allow to not declare GET item operation

features/bootstrap/DoctrineContext.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyCustomMutation as DummyCustomMutationDocument;
3232
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyCustomQuery as DummyCustomQueryDocument;
3333
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDate as DummyDateDocument;
34+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDifferentGraphQlSerializationGroup as DummyDifferentGraphQlSerializationGroupDocument;
3435
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDtoCustom as DummyDtoCustomDocument;
3536
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDtoNoInput as DummyDtoNoInputDocument;
3637
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDtoNoOutput as DummyDtoNoOutputDocument;
@@ -85,6 +86,7 @@
8586
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyCustomMutation;
8687
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyCustomQuery;
8788
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDate;
89+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDifferentGraphQlSerializationGroup;
8890
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoCustom;
8991
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoNoInput;
9092
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoNoOutput;
@@ -1224,6 +1226,21 @@ public function thereAreDummyImmutableDateObjectsWithDummyDate(int $nb)
12241226
$this->manager->flush();
12251227
}
12261228

1229+
/**
1230+
* @Given there are :nb dummy with different GraphQL serialization groups objects
1231+
*/
1232+
public function thereAreDummyWithDifferentGraphQlSerializationGroupsObjects(int $nb)
1233+
{
1234+
for ($i = 1; $i <= $nb; ++$i) {
1235+
$dummyDifferentGraphQlSerializationGroup = $this->buildDummyDifferentGraphQlSerializationGroup();
1236+
$dummyDifferentGraphQlSerializationGroup->setName('Name #'.$i);
1237+
$dummyDifferentGraphQlSerializationGroup->setTitle('Title #'.$i);
1238+
$this->manager->persist($dummyDifferentGraphQlSerializationGroup);
1239+
}
1240+
1241+
$this->manager->flush();
1242+
}
1243+
12271244
/**
12281245
* @Given there is a ramsey identified resource with uuid :uuid
12291246
*/
@@ -1583,6 +1600,14 @@ private function buildDummyDate()
15831600
return $this->isOrm() ? new DummyDate() : new DummyDateDocument();
15841601
}
15851602

1603+
/**
1604+
* @return DummyDifferentGraphQlSerializationGroup|DummyDifferentGraphQlSerializationGroupDocument
1605+
*/
1606+
private function buildDummyDifferentGraphQlSerializationGroup()
1607+
{
1608+
return $this->isOrm() ? new DummyDifferentGraphQlSerializationGroup() : new DummyDifferentGraphQlSerializationGroupDocument();
1609+
}
1610+
15861611
/**
15871612
* @return DummyDtoNoInput|DummyDtoNoInputDocument
15881613
*/

features/graphql/collection.feature

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: GraphQL collection support
99
...dummyFields
1010
}
1111
}
12-
fragment dummyFields on DummyCollectionConnection {
12+
fragment dummyFields on DummyConnection {
1313
edges {
1414
node {
1515
id
@@ -656,3 +656,27 @@ Feature: GraphQL collection support
656656
And the response should be in JSON
657657
And the header "Content-Type" should be equal to "application/json"
658658
And the JSON node "data.dummies.edges[1].node.name_converted" should be equal to "Converted 2"
659+
660+
@createSchema
661+
Scenario: Retrieve a collection with different serialization groups for item_query and collection_query
662+
Given there are 3 dummy with different GraphQL serialization groups objects
663+
When I send the following GraphQL request:
664+
"""
665+
{
666+
dummyDifferentGraphQlSerializationGroups {
667+
edges {
668+
node {
669+
name
670+
}
671+
}
672+
}
673+
}
674+
"""
675+
Then the response status code should be 200
676+
And the response should be in JSON
677+
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[0].node.name" should exist
678+
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[1].node.name" should exist
679+
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[2].node.name" should exist
680+
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[0].node.title" should not exist
681+
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[1].node.title" should not exist
682+
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[2].node.title" should not exist

features/graphql/input_output.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Feature: GraphQL DTO input and output
107107
{
108108
"errors": [
109109
{
110-
"message": "Cannot query field \"id\" on type \"DummyDtoNoOutputItem\".",
110+
"message": "Cannot query field \"id\" on type \"DummyDtoNoOutput\".",
111111
"extensions": {
112112
"category": "graphql"
113113
},

features/graphql/introspection.feature

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Feature: GraphQL introspection support
2121
When I send the following GraphQL request:
2222
"""
2323
{
24-
type1: __type(name: "DummyProductItem") {
24+
type1: __type(name: "DummyProduct") {
2525
description,
2626
fields {
2727
name
@@ -35,7 +35,7 @@ Feature: GraphQL introspection support
3535
}
3636
}
3737
}
38-
type2: __type(name: "DummyAggregateOfferItemConnection") {
38+
type2: __type(name: "DummyAggregateOfferConnection") {
3939
description,
4040
fields {
4141
name
@@ -49,7 +49,7 @@ Feature: GraphQL introspection support
4949
}
5050
}
5151
}
52-
type3: __type(name: "DummyAggregateOfferItemEdge") {
52+
type3: __type(name: "DummyAggregateOfferEdge") {
5353
description,
5454
fields {
5555
name
@@ -69,12 +69,53 @@ Feature: GraphQL introspection support
6969
And the response should be in JSON
7070
And the header "Content-Type" should be equal to "application/json"
7171
And the JSON node "data.type1.description" should be equal to "Dummy Product."
72-
And the JSON node "data.type1.fields[1].type.name" should be equal to "DummyAggregateOfferItemConnection"
72+
And the JSON node "data.type1.fields[1].type.name" should be equal to "DummyAggregateOfferConnection"
7373
And the JSON node "data.type2.fields[0].name" should be equal to "edges"
74-
And the JSON node "data.type2.fields[0].type.ofType.name" should be equal to "DummyAggregateOfferItemEdge"
74+
And the JSON node "data.type2.fields[0].type.ofType.name" should be equal to "DummyAggregateOfferEdge"
7575
And the JSON node "data.type3.fields[0].name" should be equal to "node"
7676
And the JSON node "data.type3.fields[1].name" should be equal to "cursor"
77-
And the JSON node "data.type3.fields[0].type.name" should be equal to "DummyAggregateOfferItem"
77+
And the JSON node "data.type3.fields[0].type.name" should be equal to "DummyAggregateOffer"
78+
79+
Scenario: Introspect types with different serialization groups for item_query and collection_query
80+
When I send the following GraphQL request:
81+
"""
82+
{
83+
type1: __type(name: "DummyDifferentGraphQlSerializationGroupCollection") {
84+
description,
85+
fields {
86+
name
87+
type {
88+
name
89+
kind
90+
ofType {
91+
name
92+
kind
93+
}
94+
}
95+
}
96+
}
97+
type2: __type(name: "DummyDifferentGraphQlSerializationGroupItem") {
98+
description,
99+
fields {
100+
name
101+
type {
102+
name
103+
kind
104+
ofType {
105+
name
106+
kind
107+
}
108+
}
109+
}
110+
}
111+
}
112+
"""
113+
Then the response status code should be 200
114+
And the response should be in JSON
115+
And the header "Content-Type" should be equal to "application/json"
116+
And the JSON node "data.type1.description" should be equal to "Dummy with different serialization groups for item_query and collection_query."
117+
And the JSON node "data.type1.fields[3].name" should not exist
118+
And the JSON node "data.type2.fields[3].name" should be equal to "title"
78119

79120
Scenario: Introspect deprecated queries
80121
When I send the following GraphQL request:
@@ -121,7 +162,7 @@ Feature: GraphQL introspection support
121162
When I send the following GraphQL request:
122163
"""
123164
{
124-
__type(name: "DeprecatedResourceItem") {
165+
__type(name: "DeprecatedResource") {
125166
fields(includeDeprecated: true) {
126167
name
127168
isDeprecated
@@ -224,7 +265,7 @@ Feature: GraphQL introspection support
224265
When I send the following GraphQL request:
225266
"""
226267
{
227-
__type(name: "DummyItem") {
268+
__type(name: "Dummy") {
228269
description,
229270
fields {
230271
name
@@ -250,7 +291,7 @@ Feature: GraphQL introspection support
250291
When I send the following GraphQL request:
251292
"""
252293
{
253-
typeQuery: __type(name: "DummyGroupItem") {
294+
typeQuery: __type(name: "DummyGroup") {
254295
description,
255296
fields {
256297
name
@@ -390,7 +431,7 @@ Feature: GraphQL introspection support
390431
When I send the following GraphQL request:
391432
"""
392433
{
393-
dummyItem: dummy(id: "/dummies/3") {
434+
dummy: dummy(id: "/dummies/3") {
394435
name
395436
relatedDummy {
396437
id
@@ -403,6 +444,6 @@ Feature: GraphQL introspection support
403444
Then the response status code should be 200
404445
And the response should be in JSON
405446
And the header "Content-Type" should be equal to "application/json"
406-
And the JSON node "data.dummyItem.name" should be equal to "Dummy #3"
407-
And the JSON node "data.dummyItem.relatedDummy.name" should be equal to "RelatedDummy #3"
408-
And the JSON node "data.dummyItem.relatedDummy.__typename" should be equal to "RelatedDummyItem"
447+
And the JSON node "data.dummy.name" should be equal to "Dummy #3"
448+
And the JSON node "data.dummy.relatedDummy.name" should be equal to "RelatedDummy #3"
449+
And the JSON node "data.dummy.relatedDummy.__typename" should be equal to "RelatedDummy"

features/graphql/mutation.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Feature: GraphQL mutation support
6161
And the header "Content-Type" should be equal to "application/json"
6262
And the JSON node "data.createFoo.foo.id" should be equal to "/foos/1"
6363
And the JSON node "data.createFoo.foo._id" should be equal to 1
64-
And the JSON node "data.createFoo.foo.__typename" should be equal to "FooItem"
64+
And the JSON node "data.createFoo.foo.__typename" should be equal to "Foo"
6565
And the JSON node "data.createFoo.foo.name" should be equal to "A new one"
6666
And the JSON node "data.createFoo.foo.bar" should be equal to "new"
6767
And the JSON node "data.createFoo.clientMutationId" should be equal to "myId"
@@ -113,7 +113,7 @@ Feature: GraphQL mutation support
113113
And the JSON node "data.createDummy.dummy.name" should be equal to "A dummy"
114114
And the JSON node "data.createDummy.dummy.foo" should have 0 elements
115115
And the JSON node "data.createDummy.dummy.relatedDummy.name" should be equal to "RelatedDummy #1"
116-
And the JSON node "data.createDummy.dummy.relatedDummy.__typename" should be equal to "RelatedDummyItem"
116+
And the JSON node "data.createDummy.dummy.relatedDummy.__typename" should be equal to "RelatedDummy"
117117
And the JSON node "data.createDummy.dummy.name_converted" should be equal to "Converted"
118118
And the JSON node "data.createDummy.clientMutationId" should be equal to "myId"
119119

features/graphql/query.feature

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature: GraphQL query support
2525
{
2626
node(id: "/dummies/1") {
2727
id
28-
... on DummyItem {
28+
... on Dummy {
2929
name
3030
}
3131
}
@@ -395,3 +395,20 @@ Feature: GraphQL query support
395395
}
396396
}
397397
"""
398+
399+
@createSchema
400+
Scenario: Retrieve an item with different serialization groups for item_query and collection_query
401+
Given there are 1 dummy with different GraphQL serialization groups objects
402+
When I send the following GraphQL request:
403+
"""
404+
{
405+
dummyDifferentGraphQlSerializationGroup(id: "/dummy_different_graph_ql_serialization_groups/1") {
406+
name
407+
title
408+
}
409+
}
410+
"""
411+
Then the response status code should be 200
412+
And the header "Content-Type" should be equal to "application/json"
413+
And the JSON node "data.dummyDifferentGraphQlSerializationGroup.name" should be equal to "Name #1"
414+
And the JSON node "data.dummyDifferentGraphQlSerializationGroup.title" should be equal to "Title #1"

0 commit comments

Comments
 (0)