Skip to content

Commit

Permalink
Comment problematic code parts
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoulain committed Apr 23, 2018
1 parent c605d81 commit 311525d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 38 deletions.
76 changes: 40 additions & 36 deletions features/graphql/mutation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -106,43 +106,47 @@ Feature: GraphQL mutation support
And the JSON node "data.createDummy.arrayData[1]" should be equal to baz
And the JSON node "data.createDummy.clientMutationId" should be equal to "myId"

Scenario: Create an item with an embedded field
When I send the following GraphQL request:
"""
mutation {
createRelatedDummy(input: {_id: 2, symfony: "symfony", embeddedDummy: {dummyName: "Embedded"}, clientMutationId: "myId"}) {
id
clientMutationId
}
}
"""
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.createRelatedDummy.id" should be equal to "/related_dummies/2"
And the JSON node "data.createRelatedDummy.clientMutationId" should be equal to "myId"
# @TODO StringIterableUnionInput is not used for now because it breaks graphql-php and GraphiQL.
# Waiting for https://github.com/facebook/graphql/pull/395 to be merged.
# Scenario: Create an item with an embedded field
# When I send the following GraphQL request:
# """
# mutation {
# createRelatedDummy(input: {_id: 2, symfony: "symfony", embeddedDummy: {dummyName: "Embedded"}, clientMutationId: "myId"}) {
# id
# clientMutationId
# }
# }
# """
# 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.createRelatedDummy.id" should be equal to "/related_dummies/2"
# And the JSON node "data.createRelatedDummy.clientMutationId" should be equal to "myId"

Scenario: Create an item and update a nested resource through a mutation
When I send the following GraphQL request:
"""
mutation {
createRelationEmbedder(input: {paris: "paris", krondstadt: "Krondstadt", anotherRelated: {id: 2, symfony: "laravel"}, clientMutationId: "myId"}) {
id
anotherRelated {
id
symfony
}
clientMutationId
}
}
"""
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.createRelationEmbedder.id" should be equal to "/relation_embedders/1"
And the JSON node "data.createRelationEmbedder.anotherRelated.id" should be equal to "/related_dummies/2"
And the JSON node "data.createRelationEmbedder.anotherRelated.symfony" should be equal to "laravel"
And the JSON node "data.createRelationEmbedder.clientMutationId" should be equal to "myId"
# @TODO StringIterableUnionInput is not used for now because it breaks graphql-php and GraphiQL.
# Waiting for https://github.com/facebook/graphql/pull/395 to be merged.
# Scenario: Create an item and update a nested resource through a mutation
# When I send the following GraphQL request:
# """
# mutation {
# createRelationEmbedder(input: {paris: "paris", krondstadt: "Krondstadt", anotherRelated: {id: 2, symfony: "laravel"}, clientMutationId: "myId"}) {
# id
# anotherRelated {
# id
# symfony
# }
# clientMutationId
# }
# }
# """
# 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.createRelationEmbedder.id" should be equal to "/relation_embedders/1"
# And the JSON node "data.createRelationEmbedder.anotherRelated.id" should be equal to "/related_dummies/2"
# And the JSON node "data.createRelationEmbedder.anotherRelated.symfony" should be equal to "laravel"
# And the JSON node "data.createRelationEmbedder.clientMutationId" should be equal to "myId"

Scenario: Delete an item through a mutation
When I send the following GraphQL request:
Expand Down
8 changes: 6 additions & 2 deletions src/GraphQl/Type/SchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ private function convertType(Type $type, bool $input = false, string $mutationNa
break;
case Type::BUILTIN_TYPE_OBJECT:
if ($input && $depth > 0) {
if (!isset($this->graphqlTypes['#stringIterableUnionInput'])) {
/* @TODO Don't use StringIterableUnionInput for now because it breaks graphql-php and GraphiQL.
* Waiting for https://github.com/facebook/graphql/pull/395 to be merged.
*/
/*if (!isset($this->graphqlTypes['#stringIterableUnionInput'])) {
$this->graphqlTypes['#stringIterableUnionInput'] = new InputUnionType([
'name' => 'StringIterableUnionInput',
'description' => 'Resource\'s IRI or data (embedded entities or when updating a related existing resource)',
Expand All @@ -357,7 +360,8 @@ private function convertType(Type $type, bool $input = false, string $mutationNa
],
]);
}
$graphqlType = $this->graphqlTypes['#stringIterableUnionInput'];
$graphqlType = $this->graphqlTypes['#stringIterableUnionInput'];*/
$graphqlType = GraphQLType::string();
break;
}
if (is_a($type->getClassName(), \DateTimeInterface::class, true)) {
Expand Down

0 comments on commit 311525d

Please sign in to comment.