Skip to content

Commit

Permalink
Merge branch '2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Oct 1, 2019
2 parents 8e28a58 + 97d765b commit e468d98
Show file tree
Hide file tree
Showing 21 changed files with 459 additions and 135 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2.5.0

* Fix BC-break when using short-syntax notation for `access_control`
* Fix BC-break when no item operations are declared
* GraphQL: Adding serialization group difference condition for `item_query` and `collection_query` types
* JSON Schema: Fix command

## 2.5.0 beta 3

* GraphQL: Use different types (`MyTypeItem` and `MyTypeCollection`) only if serialization groups are different for `item_query` and `collection_query` (#3083)

## 2.5.0 beta 2

* Allow to not declare GET item operation
Expand Down
25 changes: 25 additions & 0 deletions features/bootstrap/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyCustomMutation as DummyCustomMutationDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyCustomQuery as DummyCustomQueryDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDate as DummyDateDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDifferentGraphQlSerializationGroup as DummyDifferentGraphQlSerializationGroupDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDtoCustom as DummyDtoCustomDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDtoNoInput as DummyDtoNoInputDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyDtoNoOutput as DummyDtoNoOutputDocument;
Expand Down Expand Up @@ -85,6 +86,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyCustomMutation;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyCustomQuery;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDate;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDifferentGraphQlSerializationGroup;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoCustom;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoNoInput;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyDtoNoOutput;
Expand Down Expand Up @@ -1224,6 +1226,21 @@ public function thereAreDummyImmutableDateObjectsWithDummyDate(int $nb)
$this->manager->flush();
}

/**
* @Given there are :nb dummy with different GraphQL serialization groups objects
*/
public function thereAreDummyWithDifferentGraphQlSerializationGroupsObjects(int $nb)
{
for ($i = 1; $i <= $nb; ++$i) {
$dummyDifferentGraphQlSerializationGroup = $this->buildDummyDifferentGraphQlSerializationGroup();
$dummyDifferentGraphQlSerializationGroup->setName('Name #'.$i);
$dummyDifferentGraphQlSerializationGroup->setTitle('Title #'.$i);
$this->manager->persist($dummyDifferentGraphQlSerializationGroup);
}

$this->manager->flush();
}

/**
* @Given there is a ramsey identified resource with uuid :uuid
*/
Expand Down Expand Up @@ -1583,6 +1600,14 @@ private function buildDummyDate()
return $this->isOrm() ? new DummyDate() : new DummyDateDocument();
}

/**
* @return DummyDifferentGraphQlSerializationGroup|DummyDifferentGraphQlSerializationGroupDocument
*/
private function buildDummyDifferentGraphQlSerializationGroup()
{
return $this->isOrm() ? new DummyDifferentGraphQlSerializationGroup() : new DummyDifferentGraphQlSerializationGroupDocument();
}

/**
* @return DummyDtoNoInput|DummyDtoNoInputDocument
*/
Expand Down
26 changes: 25 additions & 1 deletion features/graphql/collection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: GraphQL collection support
...dummyFields
}
}
fragment dummyFields on DummyCollectionConnection {
fragment dummyFields on DummyConnection {
edges {
node {
id
Expand Down Expand Up @@ -656,3 +656,27 @@ Feature: GraphQL collection support
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.dummies.edges[1].node.name_converted" should be equal to "Converted 2"

@createSchema
Scenario: Retrieve a collection with different serialization groups for item_query and collection_query
Given there are 3 dummy with different GraphQL serialization groups objects
When I send the following GraphQL request:
"""
{
dummyDifferentGraphQlSerializationGroups {
edges {
node {
name
}
}
}
}
"""
Then the response status code should be 200
And the response should be in JSON
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[0].node.name" should exist
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[1].node.name" should exist
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[2].node.name" should exist
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[0].node.title" should not exist
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[1].node.title" should not exist
And the JSON node "data.dummyDifferentGraphQlSerializationGroups.edges[2].node.title" should not exist
2 changes: 1 addition & 1 deletion features/graphql/input_output.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Feature: GraphQL DTO input and output
{
"errors": [
{
"message": "Cannot query field \"id\" on type \"DummyDtoNoOutputItem\".",
"message": "Cannot query field \"id\" on type \"DummyDtoNoOutput\".",
"extensions": {
"category": "graphql"
},
Expand Down
67 changes: 54 additions & 13 deletions features/graphql/introspection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: GraphQL introspection support
When I send the following GraphQL request:
"""
{
type1: __type(name: "DummyProductItem") {
type1: __type(name: "DummyProduct") {
description,
fields {
name
Expand All @@ -35,7 +35,7 @@ Feature: GraphQL introspection support
}
}
}
type2: __type(name: "DummyAggregateOfferItemConnection") {
type2: __type(name: "DummyAggregateOfferConnection") {
description,
fields {
name
Expand All @@ -49,7 +49,7 @@ Feature: GraphQL introspection support
}
}
}
type3: __type(name: "DummyAggregateOfferItemEdge") {
type3: __type(name: "DummyAggregateOfferEdge") {
description,
fields {
name
Expand All @@ -69,12 +69,53 @@ Feature: GraphQL introspection support
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.type1.description" should be equal to "Dummy Product."
And the JSON node "data.type1.fields[1].type.name" should be equal to "DummyAggregateOfferItemConnection"
And the JSON node "data.type1.fields[1].type.name" should be equal to "DummyAggregateOfferConnection"
And the JSON node "data.type2.fields[0].name" should be equal to "edges"
And the JSON node "data.type2.fields[0].type.ofType.name" should be equal to "DummyAggregateOfferItemEdge"
And the JSON node "data.type2.fields[0].type.ofType.name" should be equal to "DummyAggregateOfferEdge"
And the JSON node "data.type3.fields[0].name" should be equal to "node"
And the JSON node "data.type3.fields[1].name" should be equal to "cursor"
And the JSON node "data.type3.fields[0].type.name" should be equal to "DummyAggregateOfferItem"
And the JSON node "data.type3.fields[0].type.name" should be equal to "DummyAggregateOffer"

Scenario: Introspect types with different serialization groups for item_query and collection_query
When I send the following GraphQL request:
"""
{
type1: __type(name: "DummyDifferentGraphQlSerializationGroupCollection") {
description,
fields {
name
type {
name
kind
ofType {
name
kind
}
}
}
}
type2: __type(name: "DummyDifferentGraphQlSerializationGroupItem") {
description,
fields {
name
type {
name
kind
ofType {
name
kind
}
}
}
}
}
"""
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.type1.description" should be equal to "Dummy with different serialization groups for item_query and collection_query."
And the JSON node "data.type1.fields[3].name" should not exist
And the JSON node "data.type2.fields[3].name" should be equal to "title"

Scenario: Introspect deprecated queries
When I send the following GraphQL request:
Expand Down Expand Up @@ -121,7 +162,7 @@ Feature: GraphQL introspection support
When I send the following GraphQL request:
"""
{
__type(name: "DeprecatedResourceItem") {
__type(name: "DeprecatedResource") {
fields(includeDeprecated: true) {
name
isDeprecated
Expand Down Expand Up @@ -224,7 +265,7 @@ Feature: GraphQL introspection support
When I send the following GraphQL request:
"""
{
__type(name: "DummyItem") {
__type(name: "Dummy") {
description,
fields {
name
Expand All @@ -250,7 +291,7 @@ Feature: GraphQL introspection support
When I send the following GraphQL request:
"""
{
typeQuery: __type(name: "DummyGroupItem") {
typeQuery: __type(name: "DummyGroup") {
description,
fields {
name
Expand Down Expand Up @@ -390,7 +431,7 @@ Feature: GraphQL introspection support
When I send the following GraphQL request:
"""
{
dummyItem: dummy(id: "/dummies/3") {
dummy: dummy(id: "/dummies/3") {
name
relatedDummy {
id
Expand All @@ -403,6 +444,6 @@ Feature: GraphQL introspection support
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.dummyItem.name" should be equal to "Dummy #3"
And the JSON node "data.dummyItem.relatedDummy.name" should be equal to "RelatedDummy #3"
And the JSON node "data.dummyItem.relatedDummy.__typename" should be equal to "RelatedDummyItem"
And the JSON node "data.dummy.name" should be equal to "Dummy #3"
And the JSON node "data.dummy.relatedDummy.name" should be equal to "RelatedDummy #3"
And the JSON node "data.dummy.relatedDummy.__typename" should be equal to "RelatedDummy"
4 changes: 2 additions & 2 deletions features/graphql/mutation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Feature: GraphQL mutation support
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.createFoo.foo.id" should be equal to "/foos/1"
And the JSON node "data.createFoo.foo._id" should be equal to 1
And the JSON node "data.createFoo.foo.__typename" should be equal to "FooItem"
And the JSON node "data.createFoo.foo.__typename" should be equal to "Foo"
And the JSON node "data.createFoo.foo.name" should be equal to "A new one"
And the JSON node "data.createFoo.foo.bar" should be equal to "new"
And the JSON node "data.createFoo.clientMutationId" should be equal to "myId"
Expand Down Expand Up @@ -113,7 +113,7 @@ Feature: GraphQL mutation support
And the JSON node "data.createDummy.dummy.name" should be equal to "A dummy"
And the JSON node "data.createDummy.dummy.foo" should have 0 elements
And the JSON node "data.createDummy.dummy.relatedDummy.name" should be equal to "RelatedDummy #1"
And the JSON node "data.createDummy.dummy.relatedDummy.__typename" should be equal to "RelatedDummyItem"
And the JSON node "data.createDummy.dummy.relatedDummy.__typename" should be equal to "RelatedDummy"
And the JSON node "data.createDummy.dummy.name_converted" should be equal to "Converted"
And the JSON node "data.createDummy.clientMutationId" should be equal to "myId"

Expand Down
19 changes: 18 additions & 1 deletion features/graphql/query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: GraphQL query support
{
node(id: "/dummies/1") {
id
... on DummyItem {
... on Dummy {
name
}
}
Expand Down Expand Up @@ -395,3 +395,20 @@ Feature: GraphQL query support
}
}
"""

@createSchema
Scenario: Retrieve an item with different serialization groups for item_query and collection_query
Given there are 1 dummy with different GraphQL serialization groups objects
When I send the following GraphQL request:
"""
{
dummyDifferentGraphQlSerializationGroup(id: "/dummy_different_graph_ql_serialization_groups/1") {
name
title
}
}
"""
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.dummyDifferentGraphQlSerializationGroup.name" should be equal to "Name #1"
And the JSON node "data.dummyDifferentGraphQlSerializationGroup.title" should be equal to "Title #1"
Loading

0 comments on commit e468d98

Please sign in to comment.