forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(graphql): type builder output (api-platform#4791)
* Revert "fix(graphql): output creates its own type in TypeBuilder (api-platform#4766)" This reverts commit 1f4085e. * fix: resources order
- Loading branch information
Showing
10 changed files
with
241 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,31 +13,79 @@ | |
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\Document; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\GraphQl\Mutation; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\OutputDto; | ||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
/** | ||
* Dummy with a custom GraphQL mutation resolver. | ||
* | ||
* @ODM\Document | ||
* @ApiResource(graphql={ | ||
* "sum"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}} | ||
* }, | ||
* "sumNotPersisted"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom_not_persisted", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}} | ||
* }, | ||
* "sumNoWriteCustomResult"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom_no_write_custom_result", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}}, | ||
* "write"=false | ||
* }, | ||
* "sumOnlyPersist"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom_only_persist_document", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}}, | ||
* "read"=false, | ||
* "deserialize"=false, | ||
* "validate"=false, | ||
* "serialize"=false | ||
* }, | ||
* "testCustomArguments"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom", | ||
* "args"={"operandC"={"type"="Int!"}} | ||
* } | ||
* }) | ||
* | ||
* @author Raoul Clais <[email protected]> | ||
*/ | ||
#[ApiResource(graphQlOperations: [new Mutation(name: 'sum', resolver: 'app.graphql.mutation_resolver.dummy_custom', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']]), new Mutation(name: 'sumNotPersisted', resolver: 'app.graphql.mutation_resolver.dummy_custom_not_persisted', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']]), new Mutation(name: 'sumNoWriteCustomResult', resolver: 'app.graphql.mutation_resolver.dummy_custom_no_write_custom_result', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']], write: false), new Mutation(name: 'sumOnlyPersist', resolver: 'app.graphql.mutation_resolver.dummy_custom_only_persist_document', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']], read: false, deserialize: false, validate: false, serialize: false), new Mutation(name: 'testCustomArguments', resolver: 'app.graphql.mutation_resolver.dummy_custom', args: ['operandC' => ['type' => 'Int!']]), new Mutation(name: 'testOutput', resolver: 'app.graphql.mutation_resolver.dummy_custom', output: OutputDto::class)])] | ||
#[ODM\Document] | ||
class DummyCustomMutation | ||
{ | ||
#[ODM\Id(strategy: 'INCREMENT', type: 'int')] | ||
private ?int $id = null; | ||
#[ODM\Field(type: 'int')] | ||
private ?int $operandA = null; | ||
#[Groups(['sum'])] | ||
#[ODM\Field(type: 'int', nullable: true)] | ||
private ?int $operandB = null; | ||
#[Groups(['result'])] | ||
#[ODM\Field(type: 'int', nullable: true)] | ||
private ?int $result = null; | ||
/** | ||
* @var int|null | ||
* | ||
* @ODM\Id(strategy="INCREMENT", type="int") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var int|null | ||
* | ||
* @ODM\Field(type="int") | ||
*/ | ||
private $operandA; | ||
|
||
/** | ||
* @var int|null | ||
* | ||
* @Groups({"sum"}) | ||
* @ODM\Field(type="int", nullable=true) | ||
*/ | ||
private $operandB; | ||
|
||
/** | ||
* @var int|null | ||
* | ||
* @Groups({"result"}) | ||
* @ODM\Field(type="int", nullable=true) | ||
*/ | ||
private $result; | ||
|
||
public function getId(): ?int | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,30 +13,71 @@ | |
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\Document; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\GraphQl\Query; | ||
use ApiPlatform\Metadata\GraphQl\QueryCollection; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\OutputDto; | ||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
|
||
/** | ||
* Dummy with custom GraphQL query resolvers. | ||
* | ||
* @author Lukas Lücke <[email protected]> | ||
* | ||
* @ApiResource(graphql={ | ||
* "testItem"={ | ||
* "item_query"="app.graphql.query_resolver.dummy_custom_item" | ||
* }, | ||
* "testNotRetrievedItem"={ | ||
* "item_query"="app.graphql.query_resolver.dummy_custom_not_retrieved_item_document", | ||
* "args"={} | ||
* }, | ||
* "testNoReadAndSerializeItem"={ | ||
* "item_query"="app.graphql.query_resolver.dummy_custom_item_no_read_and_serialize_document", | ||
* "read"=false, | ||
* "serialize"=false | ||
* }, | ||
* "testItemCustomArguments"={ | ||
* "item_query"="app.graphql.query_resolver.dummy_custom_item", | ||
* "args"={ | ||
* "id"={"type"="ID"}, | ||
* "customArgumentNullableBool"={"type"="Boolean"}, | ||
* "customArgumentBool"={"type"="Boolean!"}, | ||
* "customArgumentInt"={"type"="Int!"}, | ||
* "customArgumentString"={"type"="String!"}, | ||
* "customArgumentFloat"={"type"="Float!"}, | ||
* "customArgumentIntArray"={"type"="[Int!]!"}, | ||
* "customArgumentCustomType"={"type"="DateTime!"} | ||
* } | ||
* }, | ||
* "testCollection"={ | ||
* "collection_query"="app.graphql.query_resolver.dummy_custom_collection" | ||
* }, | ||
* "testCollectionNoReadAndSerialize"={ | ||
* "collection_query"="app.graphql.query_resolver.dummy_custom_collection_no_read_and_serialize", | ||
* "read"=false, | ||
* "serialize"=false | ||
* }, | ||
* "testCollectionCustomArguments"={ | ||
* "collection_query"="app.graphql.query_resolver.dummy_custom_collection", | ||
* "args"={ | ||
* "customArgumentString"={"type"="String!"} | ||
* } | ||
* } | ||
* }) | ||
* @ODM\Document | ||
*/ | ||
#[ApiResource(graphQlOperations: [new Query(name: 'testItem', resolver: 'app.graphql.query_resolver.dummy_custom_item'), new Query(name: 'testNotRetrievedItem', resolver: 'app.graphql.query_resolver.dummy_custom_not_retrieved_item_document', args: []), new Query(name: 'testNoReadAndSerializeItem', resolver: 'app.graphql.query_resolver.dummy_custom_item_no_read_and_serialize_document', read: false, serialize: false), new Query(name: 'testItemCustomArguments', resolver: 'app.graphql.query_resolver.dummy_custom_item', args: ['id' => ['type' => 'ID'], 'customArgumentNullableBool' => ['type' => 'Boolean'], 'customArgumentBool' => ['type' => 'Boolean!'], 'customArgumentInt' => ['type' => 'Int!'], 'customArgumentString' => ['type' => 'String!'], 'customArgumentFloat' => ['type' => 'Float!'], 'customArgumentIntArray' => ['type' => '[Int!]!'], 'customArgumentCustomType' => ['type' => 'DateTime!']]), new Query(name: 'testItemOutput', resolver: 'app.graphql.query_resolver.dummy_custom_item', output: OutputDto::class), new QueryCollection(name: 'testCollection', resolver: 'app.graphql.query_resolver.dummy_custom_collection'), new QueryCollection(name: 'testCollectionNoReadAndSerialize', resolver: 'app.graphql.query_resolver.dummy_custom_collection_no_read_and_serialize', read: false, serialize: false), new QueryCollection(name: 'testCollectionCustomArguments', resolver: 'app.graphql.query_resolver.dummy_custom_collection', args: ['customArgumentString' => ['type' => 'String!']])])] | ||
#[ODM\Document] | ||
class DummyCustomQuery | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ODM\Id(strategy="INCREMENT", type="int") | ||
*/ | ||
#[ODM\Id(strategy: 'INCREMENT', type: 'int')] | ||
public $id; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $message; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,33 +13,81 @@ | |
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\GraphQl\Mutation; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\OutputDto; | ||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
/** | ||
* Dummy with a custom GraphQL mutation resolver. | ||
* | ||
* @ORM\Entity | ||
* @ApiResource(graphql={ | ||
* "sum"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}} | ||
* }, | ||
* "sumNotPersisted"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom_not_persisted", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}} | ||
* }, | ||
* "sumNoWriteCustomResult"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom_no_write_custom_result", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}}, | ||
* "write"=false | ||
* }, | ||
* "sumOnlyPersist"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom_only_persist", | ||
* "normalization_context"={"groups"={"result"}}, | ||
* "denormalization_context"={"groups"={"sum"}}, | ||
* "read"=false, | ||
* "deserialize"=false, | ||
* "validate"=false, | ||
* "serialize"=false | ||
* }, | ||
* "testCustomArguments"={ | ||
* "mutation"="app.graphql.mutation_resolver.dummy_custom", | ||
* "args"={"operandC"={"type"="Int!"}} | ||
* } | ||
* }) | ||
* | ||
* @author Raoul Clais <[email protected]> | ||
*/ | ||
#[ApiResource(graphQlOperations: [new Mutation(name: 'sum', resolver: 'app.graphql.mutation_resolver.dummy_custom', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']]), new Mutation(name: 'sumNotPersisted', resolver: 'app.graphql.mutation_resolver.dummy_custom_not_persisted', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']]), new Mutation(name: 'sumNoWriteCustomResult', resolver: 'app.graphql.mutation_resolver.dummy_custom_no_write_custom_result', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']], write: false), new Mutation(name: 'sumOnlyPersist', resolver: 'app.graphql.mutation_resolver.dummy_custom_only_persist', normalizationContext: ['groups' => ['result']], denormalizationContext: ['groups' => ['sum']], read: false, deserialize: false, validate: false, serialize: false), new Mutation(name: 'testCustomArguments', resolver: 'app.graphql.mutation_resolver.dummy_custom', args: ['operandC' => ['type' => 'Int!']]), new Mutation(name: 'testOutput', resolver: 'app.graphql.mutation_resolver.dummy_custom', output: OutputDto::class)])] | ||
#[ORM\Entity] | ||
class DummyCustomMutation | ||
{ | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue(strategy: 'AUTO')] | ||
private ?int $id = null; | ||
#[ORM\Column(type: 'integer', nullable: true)] | ||
private ?int $operandA = null; | ||
#[Groups(['sum'])] | ||
#[ORM\Column(type: 'integer', nullable: true)] | ||
private ?int $operandB = null; | ||
#[Groups(['result'])] | ||
#[ORM\Column(type: 'integer', nullable: true)] | ||
private ?int $result = null; | ||
/** | ||
* @var int|null | ||
* | ||
* @ORM\Column(type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var int|null | ||
* | ||
* @ORM\Column(type="integer", nullable=true) | ||
*/ | ||
private $operandA; | ||
|
||
/** | ||
* @var int|null | ||
* | ||
* @Groups({"sum"}) | ||
* @ORM\Column(type="integer", nullable=true) | ||
*/ | ||
private $operandB; | ||
|
||
/** | ||
* @var int|null | ||
* | ||
* @Groups({"result"}) | ||
* @ORM\Column(type="integer", nullable=true) | ||
*/ | ||
private $result; | ||
|
||
public function getId(): ?int | ||
{ | ||
|
Oops, something went wrong.