Skip to content

Commit

Permalink
exclude error ressources from graphql (#5848)
Browse files Browse the repository at this point in the history
* fix(graphql): exclude error ressources from graphql

* test

---------

Co-authored-by: josef.wagner <[email protected]>
Co-authored-by: soyuka <[email protected]>
  • Loading branch information
3 people authored Oct 4, 2023
1 parent b7a76eb commit 2080936
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/ApiResource/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
links: [new Link(rel: ContextBuilderInterface::JSONLD_NS.'error', href: 'http://www.w3.org/ns/hydra/error')]
),
new Operation(name: '_api_errors_jsonapi', outputFormats: ['jsonapi' => ['application/vnd.api+json']], normalizationContext: ['groups' => ['jsonapi'], 'skip_null_values' => true]),
]
],
graphQlOperations: []
)]
class Error extends \Exception implements ProblemExceptionInterface, HttpExceptionInterface
{
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Validator/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
]
),
new ErrorOperation(name: '_api_validation_errors_jsonapi', outputFormats: ['jsonapi' => ['application/vnd.api+json']], normalizationContext: ['groups' => ['jsonapi'], 'skip_null_values' => true]),
]
],
graphQlOperations: []
)]
final class ValidationException extends BaseValidationException implements ConstraintViolationListAwareExceptionInterface, \Stringable, ProblemExceptionInterface
{
Expand Down
5 changes: 1 addition & 4 deletions tests/Fixtures/TestBundle/Document/MaxDepthDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
use Symfony\Component\Serializer\Annotation\MaxDepth;

/**
* *
*
*
* @author Brian Fox <[email protected]>
*/
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true])]
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], graphQlOperations: [])]
#[ODM\Document]
class MaxDepthDummy
{
Expand Down
5 changes: 1 addition & 4 deletions tests/Fixtures/TestBundle/Document/MaxDepthEagerDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
use Symfony\Component\Serializer\Annotation\MaxDepth;

/**
* *
*
*
* @author Brian Fox <[email protected]>
*/
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true])]
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], graphQlOperations: [])]
#[ODM\Document]
class MaxDepthEagerDummy
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/TestBundle/Entity/DummyExceptionToStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
new Get(uriTemplate: '/dummy_exception_to_statuses/{id}', exceptionToStatus: [NotFoundException::class => 404]),
new Put(uriTemplate: '/dummy_exception_to_statuses/{id}'),
new GetCollection(uriTemplate: '/dummy_exception_to_statuses'),
]
],
graphQlOperations: []
)]
#[ApiFilter(RequiredFilter::class)]
#[ORM\Entity]
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Entity/FilterValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author Julien Deniau <[email protected]>
*/
#[ApiResource(filters: [ArrayItemsFilter::class, BoundsFilter::class, EnumFilter::class, LengthFilter::class, MultipleOfFilter::class, PatternFilter::class, RequiredFilter::class, RequiredAllowEmptyFilter::class])]
#[ApiResource(filters: [ArrayItemsFilter::class, BoundsFilter::class, EnumFilter::class, LengthFilter::class, MultipleOfFilter::class, PatternFilter::class, RequiredFilter::class, RequiredAllowEmptyFilter::class], graphQlOperations: [])]
#[ORM\Entity]
class FilterValidator
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Entity/MaxDepthDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @author Brian Fox <[email protected]>
*/
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true])]
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], graphQlOperations: [])]
#[ORM\Entity]
class MaxDepthDummy
{
Expand Down
5 changes: 1 addition & 4 deletions tests/Fixtures/TestBundle/Entity/MaxDepthEagerDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
use Symfony\Component\Serializer\Annotation\MaxDepth;

/**
* *
*
*
* @author Brian Fox <[email protected]>
*/
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true])]
#[ApiResource(normalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], denormalizationContext: ['groups' => ['default'], 'enable_max_depth' => true], graphQlOperations: [])]
#[ORM\Entity]
class MaxDepthEagerDummy
{
Expand Down

0 comments on commit 2080936

Please sign in to comment.