Skip to content

Commit 515e20e

Browse files
authored
#61 Directives testing (#96)
* Working on filtering filtering for edge types, detected a bug I will push to master separatly * Working on the filters * Added aliasing for getFilters, and fixed the last bits for filtering * Reverted a local change that made it in by mistake * Implemented edge updates * Annotations should now be working proberly * Corrected getEdge out-inbound * Removed some left over debug code * Support for getting single edges by id added * Corrected an in-/outbound * edges by id not working yet * Implemented get_edge_by_id * Working on unittests for the directives. Creation tests should be done * Tests are now completed, but needs to be verified * Corrected directives and tests to now both work * Set drop back to 'false' as standard * Small change to directives behaivour to prevent edgecase failure
1 parent 49ddd90 commit 515e20e

File tree

8 files changed

+691
-50
lines changed

8 files changed

+691
-50
lines changed

graphql-api-generator/utils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ def add_input_to_update_edge_objects(schema: GraphQLSchema):
832832
continue
833833
for t in connected_types:
834834
annotations, _ = get_field_annotations(field)
835+
835836
if len(annotations) > 0:
836837
edge_from = f'{capitalize(field_name)}EdgeFrom{t.name}'
837838
edge_input = f'_InputToUpdate{edge_from}'

graphql-resolver-generator/generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def generate(input_file, output_dir, config: dict):
3434

3535
data = {'types': [], 'types_by_key': [], 'interfaces': [], 'typeDelete': [], 'edge_types_to_delete': [], 'edge_types_to_update': [], 'edge_objects': []}
3636

37-
3837
# get list of types
3938
for type_name, _type in schema.type_map.items():
4039
if is_interface_type(_type):

graphql-resolver-generator/resources/resolver.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const resolvers = {
8888
info.schema.getType('_InputToUpdate${edgeName}'),
8989
info),
9090
% endfor
91-
91+
9292
% for type_name in data['typeDelete']:
9393
delete${type_name}: (parent, args, context, info) =>
9494
driver.deleteObject(true, context, args.id, info.schema.getType('${type_name}'), info),

graphql-server/drivers/arangodb/driver.js

Lines changed: 195 additions & 48 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sh ../../woo.sh --input directives-tests-resources/directives-tests-schema.graphql \
2+
--output ../tests/generated-directives-tests-server \
3+
--config directives-tests-resources/config.yml \
4+
--driver arangodb \
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
validate:
2+
type_names: PascalCase
3+
field_names: camelCase
4+
enum_values: PascalCase
5+
transform:
6+
type_names: PascalCase
7+
field_names: camelCase
8+
enum_values: uppercase
9+
drop_comments: true
10+
generation:
11+
add_query_type: true
12+
add_mutation_type: true
13+
# add id field to all schema types
14+
field_for_id: true
15+
# add creation date and last update date field(s) to all schema types
16+
generate_datetime: true
17+
field_for_creation_date: true
18+
field_for_last_update_date: true
19+
# add reverse edges for traversal
20+
reverse_edges: true
21+
# add edge types
22+
edge_types: true
23+
fields_for_edge_types: true
24+
# add queries
25+
query_by_id: true
26+
query_type_filter: true
27+
query_list_of: true
28+
query_by_key: true
29+
# add input types
30+
input_to_create_objects: true
31+
input_to_update_objects: true
32+
# add edge input types
33+
input_to_create_edge_objects: true
34+
input_to_update_edge_objects: true
35+
# add mutations
36+
create_objects: true
37+
update_objects: true
38+
delete_objects: true
39+
# add edge mutations
40+
create_edge_objects: true
41+
update_edge_objects: true
42+
delete_edge_objects: true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
directive @distinct on FIELD_DEFINITION
2+
3+
directive @noloops on FIELD_DEFINITION
4+
5+
directive @required on FIELD_DEFINITION
6+
7+
directive @requiredForTarget on FIELD_DEFINITION
8+
9+
directive @uniqueForTarget on FIELD_DEFINITION
10+
11+
directive @key(fields: [String!]!) on OBJECT
12+
13+
14+
type DistinctTest {
15+
shouldBeDistinct: [DistinctTest] @distinct
16+
dummyField: Int
17+
}
18+
19+
type NoloopsTest {
20+
possibleLoop: [NoloopsTest] @noloops
21+
dummyField: Int
22+
}
23+
24+
type RequiredForTargetTarget {
25+
dummyField: Int
26+
}
27+
28+
type RequiredForTargetTest {
29+
target: RequiredForTargetTarget @requiredForTarget
30+
}
31+
32+
type UniqueForTargetTarget {
33+
dummyField: Int
34+
}
35+
36+
type UniqueForTargetTest {
37+
target: UniqueForTargetTarget @uniqueForTarget
38+
}

0 commit comments

Comments
 (0)