Skip to content

WIP - Subresource maxDepth #1512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
e78787a
Enable FOSUser support if the bundle is installed
dunglas Sep 11, 2017
9f1be36
Merge pull request #1360 from dunglas/fosuser
soyuka Sep 12, 2017
ff72df2
Deprecate NelmioApiDoc 2 support
dunglas Sep 11, 2017
084be5b
Merge pull request #1359 from dunglas/nelmio
dunglas Sep 12, 2017
72ac53a
Merge branch '2.1'
meyerbaptiste Sep 13, 2017
fe04d6f
Fix tests and deprecations
meyerbaptiste Sep 13, 2017
0607640
Merge pull request #1368 from meyerbaptiste/merge_2.1
meyerbaptiste Sep 13, 2017
9480dc7
Add a partial paginator to prevent COUNT SQL queries
meyerbaptiste Jul 20, 2017
f21b165
Merge pull request #1292 from meyerbaptiste/paginator_performances
meyerbaptiste Sep 14, 2017
4baf715
Add payload serialize option
pierre-H Sep 12, 2017
221cb0e
Merge branch 'master' into patch-2
pierre-H Sep 15, 2017
751893a
Merge pull request #1364 from pierre-H/patch-2
dunglas Sep 18, 2017
7cee3b8
Merge branch '2.1'
dunglas Sep 21, 2017
9ae77ac
Merge branch '2.1'
dunglas Sep 21, 2017
dd41362
Merge branch '2.1'
dunglas Sep 21, 2017
7852f10
GraphQL Query support (#1358)
alanpoulain Oct 6, 2017
2d1df59
Bump branch alias to 2.2.x-dev
Oct 10, 2017
6d70782
Merge pull request #1409 from greg0ire/bump_branch_alias
Simperfit Oct 10, 2017
f6b0404
Merge branch '2.1'
dunglas Oct 11, 2017
623f6a3
Fix tests
dunglas Oct 11, 2017
5789b56
Merge pull request #1414 from dunglas/fix-tests
dunglas Oct 11, 2017
9a3c095
Improve payload support and remove duplicate code in ConstraintViolat…
dunglas Oct 11, 2017
35f7399
Filter Annotation implementation
May 16, 2017
0589ae9
Merge pull request #1117 from soyuka/feat/1033
soyuka Oct 12, 2017
85bce5e
Remove an unused var
dunglas Oct 12, 2017
f3c4bba
Merge pull request #1424 from dunglas/remove-unused
dunglas Oct 12, 2017
ee0d5d5
Enable the coverage
meyerbaptiste Oct 12, 2017
39aab7d
Merge pull request #1426 from meyerbaptiste/enable_coverage
meyerbaptiste Oct 12, 2017
6d1c91d
Fix some quality issues
dunglas Oct 12, 2017
0087cdd
Add job to test upstream libs deprecations
Oct 12, 2017
87f9b82
Merge pull request #1428 from dunglas/quality
dunglas Oct 12, 2017
5cfaf4e
Merge pull request #1430 from greg0ire/test_upstream_deprecations
dunglas Oct 12, 2017
808b5d3
Allow plain IDs with `allow_plain_identifiers`
Sep 12, 2017
318d3b3
Merge pull request #1365 from soyuka/fix/api-platform/249
soyuka Oct 13, 2017
d88168f
Fix indentation for GraphQL features.
meyerbaptiste Oct 13, 2017
c423bc0
Merge pull request #1434 from meyerbaptiste/fix_behat_graphql_indenta…
meyerbaptiste Oct 13, 2017
e7c87c6
Merge branch '2.1'
meyerbaptiste Oct 13, 2017
04aca32
Merge pull request #1435 from meyerbaptiste/merge_2.1
soyuka Oct 13, 2017
4b3d1ab
Add JSON API basic support (#785, #1036, #1175)
meyerbaptiste Oct 13, 2017
d5447b3
Merge branch '2.1'
meyerbaptiste Oct 19, 2017
62ffeae
Merge pull request #1447 from meyerbaptiste/merge_2.1
meyerbaptiste Oct 19, 2017
ad14ac0
Generator compat improvements (#1429)
greg0ire Oct 20, 2017
fce4b8c
Add support for resource names without namespace
phansys Oct 20, 2017
62383ba
Merge pull request #1451 from phansys/resourcenames_without_ns
dunglas Oct 21, 2017
c25eba9
Merge branch '2.1'
dunglas Oct 23, 2017
5439c36
Merge branch '2.1'
dunglas Oct 23, 2017
9c17299
Create a base collection normalizer
meyerbaptiste Oct 23, 2017
78a3d6d
Merge pull request #1455 from meyerbaptiste/refactor_collection_norma…
dunglas Oct 23, 2017
da8849c
Merge branch '2.1'
dunglas Oct 23, 2017
abf7e9c
Update changelog
dunglas Oct 23, 2017
d9d986d
Add a data persistence layer
meyerbaptiste Oct 25, 2017
c8f5c64
Fix dunglas' comments
meyerbaptiste Oct 30, 2017
c7e2cda
Merge pull request #1464 from meyerbaptiste/add_data_persister
dunglas Oct 30, 2017
4fa2e4a
Make it easier to configure operations
dunglas Oct 31, 2017
8a3b593
Merge pull request #1470 from dunglas/improved-operations
sroze Nov 1, 2017
08a23be
Merge remote-tracking branch 'origin/2.1'
Nov 3, 2017
80c88f9
Fix Extension Test getDefaultContainer => getBaseContainer
Nov 3, 2017
d18ec0d
Merge pull request #1477 from soyuka/merge-2.1
soyuka Nov 3, 2017
18aac52
Pass serialization context to graphql
meyerbaptiste Oct 31, 2017
bd3639f
Merge pull request #1474 from meyerbaptiste/fix_serialization_context…
dunglas Nov 7, 2017
0febda2
Add SerializerAwareInterface supports on ItemDataProvider (#1184)
vincentchalamon Nov 9, 2017
2f113f3
Merge remote-tracking branch 'origin/2.1' into merge-2.1
Nov 10, 2017
d683d00
Merge pull request #1487 from soyuka/merge-2.1
soyuka Nov 10, 2017
1e5b1ca
fix #1479
Nov 8, 2017
17c321f
Add SubresourceOperations to metadata
Nov 8, 2017
091865f
Merge pull request #1483 from soyuka/fix-subresource-override-operation
meyerbaptiste Nov 17, 2017
f0cedbc
Fix annotation filters + OrderBy autowiring capabilities
Nov 15, 2017
ba2679b
Merge pull request #1491 from soyuka/fix-autowire-orderby
soyuka Nov 20, 2017
4ad6192
[docs] Updated link in README.md (#1494)
Nov 20, 2017
11849cb
Fix typo
tuanphpvn Nov 21, 2017
20a8090
Update OrderExtensionTest.php
tuanphpvn Nov 21, 2017
2a7a7f3
Update OrderExtensionTest.php
tuanphpvn Nov 21, 2017
12fabde
Merge pull request #1504 from tuanphpvn/patch-1
dunglas Nov 22, 2017
a20686e
Merge branch '2.1'
dunglas Nov 22, 2017
63661ee
added maxDepth to ApiSubresource
Nightbr Nov 22, 2017
02e3905
WIP maxDepth
Nightbr Nov 22, 2017
8c3fe84
maxDepth
Nightbr Nov 23, 2017
0cca0ac
Merge branch '2.1'
dunglas Nov 23, 2017
0b0012d
Merge branch '2.1'
dunglas Nov 23, 2017
f28587d
Merge branch '2.1'
dunglas Nov 23, 2017
be36f2e
optimize code
Nightbr Nov 23, 2017
b879546
Merge branch 'master' into subresource_depth
Nightbr Nov 23, 2017
dc478ee
Use Brigade for coverage
meyerbaptiste Nov 17, 2017
49545a8
Remove coverage in Travis
meyerbaptiste Nov 22, 2017
f74b9a5
Fix JS CS
meyerbaptiste Nov 22, 2017
4c33762
Use a custom Docker image to speed up the builds
meyerbaptiste Nov 22, 2017
913e308
Fix JS CS
meyerbaptiste Nov 22, 2017
86993a5
added maxDepth to ApiSubresource
Nightbr Nov 22, 2017
a9f123e
WIP maxDepth
Nightbr Nov 22, 2017
fd81228
maxDepth
Nightbr Nov 23, 2017
624bf5b
Add back globally installed packaged to the path
dunglas Nov 23, 2017
2304550
Make tests green when using SF 3.4
dunglas Nov 22, 2017
d0d5fbf
optimize code
Nightbr Nov 23, 2017
c444fc7
WIP refactor + test
Nightbr Nov 23, 2017
d798481
Merge remote-tracking branch 'origin/subresource_depth' into subresou…
Nightbr Nov 23, 2017
d969095
fix
Nightbr Nov 24, 2017
e1c5e4b
yml/xml support
Nightbr Nov 24, 2017
f61b3d8
added maxDepth to ApiSubresource
Nightbr Nov 22, 2017
065a332
Merge remote-tracking branch 'origin/subresource_depth' into subresou…
Nightbr Nov 24, 2017
b2a6ca3
remove broken test
Nightbr Nov 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/vendor/
/tests/Fixtures/app/cache/*
/tests/Fixtures/app/logs/*
/.idea
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ before_install:
- export PATH="$PATH:$HOME/.composer/vendor/bin"

install:
- if [[ $deps = 'beta' ]]; then composer config minimum-stability beta; fi
- if [[ $deps != 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
- if [[ ! $deps ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi

script:
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 2.2.0

* Add GraphQL support
* Add JSONAPI support
* Add a new `@ApiFilter` annotation to directly configure filters from resource classes
* Add a partial paginator that prevents `COUNT()` SQL queries
* Add an option to serialize Validator's payloads (e.g. error levels)
* Add support for generators in data providers
* Add a new `allow_plain_identifiers` option to allow using plain IDs as identifier instead of IRIs
* Add support for resource names without namespace
* Automatically enable FOSUser support if the bundle is installed
* Add an `AbstractCollectionNormalizer` to help supporting custom formats
* Deprecate NelmioApiDocBundle 2 support (upgrade to v3, it has native API Platform support)
* Deprecate the `ApiPlatform\Core\Bridge\Doctrine\EventListener\WriteListener` class in favor of the new `ApiPlatform\Core\EventListener\WriteListener` class.
* Delete the `api_platform.doctrine.listener.view.write` event listener service.
* Add a data persistence layer with a new `ApiPlatform\Core\DataPersister\DataPersisterInterface` interface.

## 2.1.3

* Don't use dynamic values in Varnish-related service keys (improves Symfony 3.3 compatibility)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ high performance API-first projects. Extend or override everything you want.

## Documentation

The documentation of API Platform can be browsed [on the official website](https://api-platform.com/docs/).
The documentation of API Platform Core Library can be browsed [on the official website](https://api-platform.com/docs/core).
4 changes: 4 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ default:
default:
contexts:
- 'FeatureContext': { doctrine: '@doctrine' }
- 'GraphqlContext'
- 'HydraContext'
- 'SwaggerContext'
- 'HttpCacheContext'
- 'JsonApiContext': { doctrine: '@doctrine', jsonApiSchemaFile: 'tests/Fixtures/JsonSchema/jsonapi.json' }
- 'Behat\MinkExtension\Context\MinkContext'
- 'Behatch\Context\RestContext'
- 'Behatch\Context\JsonContext'
Expand All @@ -28,9 +30,11 @@ coverage:
default:
contexts:
- 'FeatureContext': { doctrine: '@doctrine' }
- 'GraphqlContext'
- 'HydraContext'
- 'SwaggerContext'
- 'HttpCacheContext'
- 'JsonApiContext': { doctrine: '@doctrine', jsonApiSchemaFile: 'tests/Fixtures/JsonSchema/jsonapi.json' }
- 'CoverageContext'
- 'Behat\MinkExtension\Context\MinkContext'
- 'Behatch\Context\RestContext'
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"doctrine/annotations": "^1.2",
"friendsofsymfony/user-bundle": "^2.0",
"guzzlehttp/guzzle": "^6.0",
"justinrainbow/json-schema": "^1.5",
"nelmio/api-doc-bundle": "^2.11.2",
"php-mock/php-mock-phpunit": "^2.0",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0",
Expand All @@ -62,7 +63,8 @@
"symfony/security-bundle": "^3.0 || ^4.0",
"symfony/twig-bundle": "^3.1 || ^4.0",
"symfony/validator": "^3.3 || ^4.0",
"symfony/yaml": "^3.3 || ^4.0"
"symfony/yaml": "^3.3 || ^4.0",
"webonyx/graphql-php": "^0.10.2"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
Expand All @@ -76,7 +78,8 @@
"symfony/expression-language": "To use authorization features.",
"symfony/config": "To load XML configuration files.",
"symfony/security": "To use authorization features.",
"symfony/twig-bundle": "To use the Swagger UI integration."
"symfony/twig-bundle": "To use the Swagger UI integration.",
"webonyx/graphql-php": "To support GraphQL."
},
"autoload": {
"psr-4": { "ApiPlatform\\Core\\": "src/" }
Expand All @@ -86,7 +89,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
"dev-master": "2.2.x-dev"
}
}
}
57 changes: 52 additions & 5 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Answer;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeItem;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeLabel;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositePrimitiveItem;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeRelation;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Container;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
Expand All @@ -38,6 +39,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedToDummyFriend;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelationEmbedder;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ThirdLevel;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\User;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UuidIdentifierDummy;
use Behat\Behat\Context\Context;
Expand Down Expand Up @@ -258,6 +260,31 @@ public function thereIsDummyObjectsWithRelatedDummy(int $nb)
$this->manager->flush();
}

/**
* @Given there is :nb dummy objects with relatedDummy and its thirdLevel
*/
public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel(int $nb)
{
for ($i = 1; $i <= $nb; ++$i) {
$thirdLevel = new ThirdLevel();

$relatedDummy = new RelatedDummy();
$relatedDummy->setName('RelatedDummy #'.$i);
$relatedDummy->setThirdLevel($thirdLevel);

$dummy = new Dummy();
$dummy->setName('Dummy #'.$i);
$dummy->setAlias('Alias #'.($nb - $i));
$dummy->setRelatedDummy($relatedDummy);

$this->manager->persist($thirdLevel);
$this->manager->persist($relatedDummy);
$this->manager->persist($dummy);
}

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

/**
* @Given there is :nb dummy objects with embeddedDummy
*/
Expand Down Expand Up @@ -341,7 +368,7 @@ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string
$bool = false;
} else {
$expected = ['true', 'false', '1', '0'];
throw new InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
}

for ($i = 1; $i <= $nb; ++$i) {
Expand Down Expand Up @@ -395,7 +422,7 @@ public function thereIsDummyObjectsWithDummyDateAndRelatedDummy(int $nb)
/**
* @Given there is :nb embedded dummy objects with dummyDate and embeddedDummy
*/
public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy($nb)
public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy(int $nb)
{
for ($i = 1; $i <= $nb; ++$i) {
$date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC'));
Expand Down Expand Up @@ -450,7 +477,7 @@ public function thereIsDummyObjectsWithDummyBoolean(int $nb, string $bool)
$bool = false;
} else {
$expected = ['true', 'false', '1', '0'];
throw new InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
}
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];

Expand Down Expand Up @@ -478,7 +505,7 @@ public function thereIsDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $boo
$bool = false;
} else {
$expected = ['true', 'false', '1', '0'];
throw new InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
}

for ($i = 1; $i <= $nb; ++$i) {
Expand All @@ -505,7 +532,7 @@ public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean(int $nb, str
$bool = false;
} else {
$expected = ['true', 'false', '1', '0'];
throw new InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
throw new \InvalidArgumentException(sprintf('Invalid boolean value for "%s" property, expected one of ( "%s" )', $bool, implode('" | "', $expected)));
}

for ($i = 1; $i <= $nb; ++$i) {
Expand Down Expand Up @@ -577,6 +604,23 @@ public function thereIsACompositeIdentifierObject()
$this->manager->clear();
}

/**
* @Given there are composite primitive identifiers objects
*/
public function thereAreCompositePrimitiveIdentifiersObjects()
{
$foo = new CompositePrimitiveItem('Foo', 2016);
$foo->setDescription('This is foo.');
$this->manager->persist($foo);

$bar = new CompositePrimitiveItem('Bar', 2017);
$bar->setDescription('This is bar.');
$this->manager->persist($bar);

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

/**
* @Given there is a FileConfigDummy object
*/
Expand All @@ -596,6 +640,9 @@ public function thereIsAFileConfigDummyObject()
public function thereIsAFooEntityWithRelatedBars()
{
$foo = new DummyCar();
$foo->setName('mustli');
$foo->setCanSell(true);
$foo->setAvailableAt(new \DateTime());
$this->manager->persist($foo);

$bar1 = new DummyCarColor();
Expand Down
95 changes: 95 additions & 0 deletions features/bootstrap/GraphqlContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use Behat\Behat\Context\Context;
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\PyStringNode;
use Behatch\Context\RestContext;
use Symfony\Component\HttpFoundation\Request;

/**
* Context for GraphQL.
*
* @author Alan Poulain <[email protected]>
*/
final class GraphqlContext implements Context
{
/**
* @var RestContext
*/
private $restContext;

/**
* @var array
*/
private $graphqlRequest;

/**
* @var int
*/
private $graphqlLine;

/**
* Gives access to the Behatch context.
*
* @BeforeScenario
*/
public function gatherContexts(BeforeScenarioScope $scope)
{
/** @var InitializedContextEnvironment $environment */
$environment = $scope->getEnvironment();
$this->restContext = $environment->getContext(RestContext::class);
}

/**
* @When I have the following GraphQL request:
*/
public function IHaveTheFollowingGraphqlRequest(PyStringNode $request)
{
$this->graphqlRequest = ['query' => $request->getRaw()];
$this->graphqlLine = $request->getLine();
}

/**
* @When I send the following GraphQL request:
*/
public function ISendTheFollowingGraphqlRequest(PyStringNode $request)
{
$this->IHaveTheFollowingGraphqlRequest($request);
$this->sendGraphqlRequest();
}

/**
* @When I send the GraphQL request with variables:
*/
public function ISendTheGraphqlRequestWithVariables(PyStringNode $variables)
{
$this->graphqlRequest['variables'] = $variables->getRaw();
$this->sendGraphqlRequest();
}

/**
* @When I send the GraphQL request with operation :operation
*/
public function ISendTheGraphqlRequestWithOperation(string $operation)
{
$this->graphqlRequest['operation'] = $operation;
$this->sendGraphqlRequest();
}

private function sendGraphqlRequest()
{
$this->restContext->iSendARequestTo(Request::METHOD_GET, '/graphql?'.http_build_query($this->graphqlRequest));
}
}
Loading