Skip to content

Commit ab8de31

Browse files
Fix review
1 parent ba95062 commit ab8de31

File tree

4 files changed

+98
-45
lines changed

4 files changed

+98
-45
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# TODO: FIXME: GraphQL support for non-resources is non-existent
2+
3+
Feature: GraphQL non-resource handling
4+
In order to use non-resource types
5+
As a developer
6+
I should be able to serialize types not mapped to an API resource.
7+
8+
Scenario: Get a resource containing a raw object
9+
Then it is not supported
10+
# When I send the following GraphQL request:
11+
# """
12+
# {
13+
# containNonResource(id: "/contain_non_resources/1") {
14+
# _id
15+
# id
16+
# nested {
17+
# _id
18+
# id
19+
# notAResource {
20+
# foo
21+
# bar
22+
# }
23+
# }
24+
# notAResource {
25+
# foo
26+
# bar
27+
# }
28+
# }
29+
# }
30+
# """
31+
# Then the response status code should be 200
32+
# And the response should be in JSON
33+
# And the header "Content-Type" should be equal to "application/json"
34+
# And the JSON should be equal to:
35+
# """
36+
# {
37+
# "data": {
38+
# "containNonResource": {
39+
# "_id": 1,
40+
# "id": "/contain_non_resources/1",
41+
# "nested": {
42+
# "_id": "1-nested",
43+
# "id": "/contain_non_resources/1-nested",
44+
# "notAResource": {
45+
# "foo": "f2",
46+
# "bar": "b2"
47+
# }
48+
# },
49+
# "notAResource": {
50+
# "foo": "f1",
51+
# "bar": "b1"
52+
# }
53+
# }
54+
# }
55+
# }
56+
# """
57+
58+
@!mongodb
59+
@createSchema
60+
Scenario: Create a resource that has a non-resource relation.
61+
Then it is not supported
62+
# When I send the following GraphQL request:
63+
# """
64+
# mutation {
65+
# createNonRelationResource(input: {relation: {foo: "test"}}) {
66+
# nonRelationResource {
67+
# _id
68+
# id
69+
# relation {
70+
# foo
71+
# }
72+
# }
73+
# }
74+
# }
75+
# """
76+
# Then the response status code should be 200
77+
# And the response should be in JSON
78+
# And the header "Content-Type" should be equal to "application/json"
79+
# And the JSON should be equal to:
80+
# """
81+
# {
82+
# "data": {
83+
# "nonRelationResource": {
84+
# "_id": 1,
85+
# "id": "/non_relation_resources/1",
86+
# "relation": {
87+
# "foo": "test"
88+
# }
89+
# }
90+
# }
91+
# }
92+
# """

features/main/table_inheritance.feature

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -351,47 +351,7 @@ Feature: Table inheritance
351351
}
352352
"""
353353

354-
@createSchema
355-
Scenario: Create a table inherited resource
356-
When I add "Content-Type" header equal to "application/ld+json"
357-
And I send a "POST" request to "/dummy_table_inheritance_children" with body:
358-
"""
359-
{"name": "foo", "nickname": "bar"}
360-
"""
361-
Then the response status code should be 201
362-
And the response should be in JSON
363-
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
364-
And the JSON should be valid according to this schema:
365-
"""
366-
{
367-
"type": "object",
368-
"properties": {
369-
"@type": {
370-
"type": "string",
371-
"pattern": "^DummyTableInheritanceChild$"
372-
},
373-
"@context": {
374-
"type": "string",
375-
"pattern": "^/contexts/DummyTableInheritanceChild$"
376-
},
377-
"@id": {
378-
"type": "string",
379-
"pattern": "^/dummy_table_inheritance_children/1$"
380-
},
381-
"name": {
382-
"type": "string",
383-
"pattern": "^foo$",
384-
"required": "true"
385-
},
386-
"nickname": {
387-
"type": "string",
388-
"pattern": "^bar$",
389-
"required": "true"
390-
}
391-
}
392-
}
393-
"""
394-
354+
@!mongodb
395355
@createSchema
396356
@dropSchema
397357
Scenario: Generate iri from parent resource
@@ -435,7 +395,7 @@ Feature: Table inheritance
435395
},
436396
"owner": {
437397
"type": "string",
438-
"pattern": "^/people/\\d+$",
398+
"pattern": "^/custom_users/\\d+$",
439399
"required": "true"
440400
}
441401
}
@@ -448,6 +408,7 @@ Feature: Table inheritance
448408
}
449409
"""
450410

411+
@!mongodb
451412
@createSchema
452413
Scenario: Generate iri from current resource even if parent class is a resource
453414
Given there are 3 sites with external owner

src/Bridge/Symfony/Routing/RouteNameResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getRouteName(string $resourceClass, $operationType /*, array $co
6666
$operation = $route->getDefault(sprintf('_api_%s_operation_name', $operationType));
6767
$methods = $route->getMethods();
6868

69-
if (null !== $currentResourceClass && is_a($resourceClass, $currentResourceClass, true) && null !== $operation && (empty($methods) || \in_array('GET', $methods, true))) {
69+
if (null !== $operation && (empty($methods) || \in_array('GET', $methods, true)) && null !== $currentResourceClass && is_a($resourceClass, $currentResourceClass, true)) {
7070
if (OperationType::SUBRESOURCE === $operationType && false === $this->isSameSubresource($context, $route->getDefault('_api_subresource_context'))) {
7171
continue;
7272
}

tests/Fixtures/TestBundle/Entity/AbstractUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
* @ORM\InheritanceType("JOINED")
2222
* @ApiResource(
2323
* collectionOperations={
24-
* "get"={"path"="/people"}
24+
* "get"={"path"="/custom_users"}
2525
* },
2626
* itemOperations={
27-
* "get"={"path"="/people/{id}"}
27+
* "get"={"path"="/custom_users/{id}"}
2828
* }
2929
* )
3030
*/

0 commit comments

Comments
 (0)