|
22 | 22 | is_input_type,
|
23 | 23 | is_output_type
|
24 | 24 | )
|
| 25 | +from ..type.directives import GraphQLDirective |
25 | 26 | from ..type.introspection import TypeKind
|
26 | 27 | from .value_from_ast import value_from_ast
|
27 | 28 |
|
@@ -194,19 +195,42 @@ def build_default_value(f):
|
194 | 195 |
|
195 | 196 | def build_input_value_def_map(input_value_introspection, argument_type):
|
196 | 197 | return OrderedDict([
|
197 |
| - (f['name'], argument_type( |
198 |
| - description=f['description'], |
199 |
| - type=get_input_type(f['type']), |
200 |
| - default_value=build_default_value(f) |
201 |
| - )) for f in input_value_introspection |
| 198 | + (f['name'], build_input_value(f, argument_type)) for f in input_value_introspection |
202 | 199 | ])
|
203 | 200 |
|
| 201 | + def build_input_value(input_value_introspection, argument_type): |
| 202 | + input_value = argument_type( |
| 203 | + description=input_value_introspection['description'], |
| 204 | + type=get_input_type(input_value_introspection['type']), |
| 205 | + default_value=build_default_value(input_value_introspection) |
| 206 | + ) |
| 207 | + input_value.name = input_value_introspection['name'] |
| 208 | + return input_value |
| 209 | + |
| 210 | + def build_directive(directive_introspection): |
| 211 | + return GraphQLDirective( |
| 212 | + name=directive_introspection['name'], |
| 213 | + description=directive_introspection['description'], |
| 214 | + args=[build_input_value(a, GraphQLArgument) for a in directive_introspection['args']], |
| 215 | + on_operation=directive_introspection['onOperation'], |
| 216 | + on_fragment=directive_introspection['onFragment'], |
| 217 | + on_field=directive_introspection['onField'] |
| 218 | + ) |
| 219 | + |
204 | 220 | for type_introspection_name in type_introspection_map:
|
205 | 221 | get_named_type(type_introspection_name)
|
206 | 222 |
|
207 |
| - query_type = get_type(schema_introspection['queryType']) |
208 |
| - mutation_type = get_type(schema_introspection['mutationType']) if schema_introspection.get('mutationType') else None |
209 |
| - subscription_type = get_type(schema_introspection['subscriptionType']) if \ |
| 223 | + query_type = get_object_type(schema_introspection['queryType']) |
| 224 | + mutation_type = get_object_type(schema_introspection['mutationType']) if schema_introspection.get('mutationType') else None |
| 225 | + subscription_type = get_object_type(schema_introspection['subscriptionType']) if \ |
210 | 226 | schema_introspection.get('subscriptionType') else None
|
211 | 227 |
|
212 |
| - return GraphQLSchema(query=query_type, mutation=mutation_type, subscription=subscription_type) |
| 228 | + directives = [build_directive(d) for d in schema_introspection['directives']] \ |
| 229 | + if schema_introspection['directives'] else [] |
| 230 | + |
| 231 | + return GraphQLSchema( |
| 232 | + query=query_type, |
| 233 | + mutation=mutation_type, |
| 234 | + subscription=subscription_type, |
| 235 | + directives=directives |
| 236 | + ) |
0 commit comments