blob: a7706610cce03d3d531ae68bcf2d001310000193 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from ariadne import SchemaDirectiveVisitor, ObjectType
from . mutations import make_configure_resolver, make_config_file_resolver
class ConfigureDirective(SchemaDirectiveVisitor):
"""
Class providing implementation of 'configure' directive in schema.
"""
def visit_field_definition(self, field, object_type):
name = f'{field.type}'
# field.type contains the return value of the mutation; trim value
# to produce canonical name
name = name.replace('Result', '', 1)
func = make_configure_resolver(name)
field.resolve = func
return field
class ConfigFileDirective(SchemaDirectiveVisitor):
"""
Class providing implementation of 'configfile' directive in schema.
"""
def visit_field_definition(self, field, object_type):
name = f'{field.type}'
# field.type contains the return value of the mutation; trim value
# to produce canonical name
name = name.replace('Result', '', 1)
func = make_config_file_resolver(name)
field.resolve = func
return field
directives_dict = {"configure": ConfigureDirective, "configfile": ConfigFileDirective}
|