|
1 |
| -# -*- coding: utf-8 -*- |
2 |
| -from ...error import GraphQLError |
3 |
| -from ...language import ast |
4 |
| -from ...pyutils.default_ordered_dict import DefaultOrderedDict |
5 |
| -from ...type.definition import GraphQLInterfaceType, GraphQLUnionType |
6 |
| -from ...type.directives import GraphQLIncludeDirective, GraphQLSkipDirective |
7 |
| -from ...type.introspection import (SchemaMetaFieldDef, TypeMetaFieldDef, |
8 |
| - TypeNameMetaFieldDef) |
9 |
| -from ...utils.type_from_ast import type_from_ast |
10 |
| -from ..values import get_argument_values, get_variable_values |
| 1 | +# # -*- coding: utf-8 -*- |
| 2 | +# from ...error import GraphQLError |
| 3 | +# from ...language import ast |
| 4 | +# from ...pyutils.default_ordered_dict import DefaultOrderedDict |
| 5 | +# from ...type.definition import GraphQLInterfaceType, GraphQLUnionType |
| 6 | +# from ...type.directives import GraphQLIncludeDirective, GraphQLSkipDirective |
| 7 | +# from ...type.introspection import (SchemaMetaFieldDef, TypeMetaFieldDef, |
| 8 | +# TypeNameMetaFieldDef) |
| 9 | +# from ...utils.type_from_ast import type_from_ast |
| 10 | +# from ..values import get_argument_values, get_variable_values |
11 | 11 |
|
12 |
| -from ...type import (GraphQLEnumType, GraphQLInterfaceType, GraphQLList, |
13 |
| - GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, |
14 |
| - GraphQLSchema, GraphQLUnionType) |
15 |
| -from ..base import (ExecutionContext, ExecutionResult, ResolveInfo, Undefined, |
16 |
| - collect_fields, default_resolve_fn, get_field_def, |
17 |
| - get_operation_root_type) |
| 12 | +# from ...type import (GraphQLEnumType, GraphQLInterfaceType, GraphQLList, |
| 13 | +# GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, |
| 14 | +# GraphQLSchema, GraphQLUnionType) |
| 15 | +# from ..base import (ExecutionContext, ExecutionResult, ResolveInfo, Undefined, |
| 16 | +# collect_fields, default_resolve_fn, get_field_def, |
| 17 | +# get_operation_root_type) |
18 | 18 |
|
19 |
| -from .fragment import Fragment |
| 19 | +# from .fragment import Fragment |
20 | 20 |
|
21 | 21 |
|
22 |
| -def get_base_type(type): |
23 |
| - if isinstance(type, (GraphQLList, GraphQLNonNull)): |
24 |
| - return get_base_type(type.of_type) |
25 |
| - return type |
| 22 | +# def get_base_type(type): |
| 23 | +# if isinstance(type, (GraphQLList, GraphQLNonNull)): |
| 24 | +# return get_base_type(type.of_type) |
| 25 | +# return type |
26 | 26 |
|
27 | 27 |
|
28 |
| -class QueryBuilder(object): |
| 28 | +# class QueryBuilder(object): |
29 | 29 |
|
30 |
| - __slots__ = 'schema', 'operations', 'fragments' |
| 30 | +# __slots__ = 'schema', 'operations', 'fragments' |
31 | 31 |
|
32 |
| - def __init__(self, schema, document_ast): |
33 |
| - operations = {} |
34 |
| - fragments = {} |
| 32 | +# def __init__(self, schema, document_ast): |
| 33 | +# operations = {} |
| 34 | +# fragments = {} |
35 | 35 |
|
36 |
| - for definition in document_ast.definitions: |
37 |
| - if isinstance(definition, ast.OperationDefinition): |
38 |
| - operation_name = definition.name.value |
39 |
| - operations[operation_name] = definition |
| 36 | +# for definition in document_ast.definitions: |
| 37 | +# if isinstance(definition, ast.OperationDefinition): |
| 38 | +# operation_name = definition.name.value |
| 39 | +# operations[operation_name] = definition |
40 | 40 |
|
41 |
| - elif isinstance(definition, ast.FragmentDefinition): |
42 |
| - fragment_name = definition.name.value |
43 |
| - fragments[fragment_name] = definition |
| 41 | +# elif isinstance(definition, ast.FragmentDefinition): |
| 42 | +# fragment_name = definition.name.value |
| 43 | +# fragments[fragment_name] = definition |
44 | 44 |
|
45 |
| - else: |
46 |
| - raise GraphQLError( |
47 |
| - u'GraphQL cannot execute a request containing a {}.'.format(definition.__class__.__name__), |
48 |
| - definition |
49 |
| - ) |
| 45 | +# else: |
| 46 | +# raise GraphQLError( |
| 47 | +# u'GraphQL cannot execute a request containing a {}.'.format(definition.__class__.__name__), |
| 48 | +# definition |
| 49 | +# ) |
50 | 50 |
|
51 |
| - if not operations: |
52 |
| - raise GraphQLError('Must provide an operation.') |
| 51 | +# if not operations: |
| 52 | +# raise GraphQLError('Must provide an operation.') |
53 | 53 |
|
54 |
| - self.fragments = fragments |
55 |
| - self.schema = schema |
56 |
| - self.operations = {} |
| 54 | +# self.fragments = fragments |
| 55 | +# self.schema = schema |
| 56 | +# self.operations = {} |
57 | 57 |
|
58 |
| - for operation_name, operation in operations.items(): |
59 |
| - self.operations[operation_name] = fragment_operation(self.schema, operation) |
| 58 | +# for operation_name, operation in operations.items(): |
| 59 | +# self.operations[operation_name] = fragment_operation(self.schema, operation) |
60 | 60 |
|
61 |
| - def get_operation_fragment(self, operation_name): |
62 |
| - return self.operations[operation_name] |
| 61 | +# def get_operation_fragment(self, operation_name): |
| 62 | +# return self.operations[operation_name] |
63 | 63 |
|
64 | 64 |
|
65 |
| -def fragment_operation(schema, operation): |
66 |
| - field_asts = operation.selection_set.selections |
67 |
| - root_type = get_operation_root_type(schema, operation) |
68 |
| - execute_serially = operation.operation == 'mutation' |
69 |
| - return generate_fragment(root_type, field_asts, execute_serially) |
| 65 | +# def fragment_operation(schema, operation): |
| 66 | +# field_asts = operation.selection_set.selections |
| 67 | +# root_type = get_operation_root_type(schema, operation) |
| 68 | +# execute_serially = operation.operation == 'mutation' |
| 69 | +# return generate_fragment(root_type, field_asts, execute_serially) |
70 | 70 |
|
71 | 71 |
|
72 |
| -def generate_fragment(type, field_asts, execute_serially=False): |
73 |
| - field_fragments = {} |
74 |
| - for field_ast in field_asts: |
75 |
| - field_name = field_ast.name.value |
76 |
| - field_def = type.fields[field_name] |
77 |
| - field_base_type = get_base_type(field_def.type) |
78 |
| - if not isinstance(field_base_type, GraphQLObjectType): |
79 |
| - continue |
80 |
| - field_fragments[field_name] = generate_fragment(field_base_type, field_ast.selection_set.selections) |
| 72 | +# def generate_fragment(type, field_asts, execute_serially=False): |
| 73 | +# field_fragments = {} |
| 74 | +# for field_ast in field_asts: |
| 75 | +# field_name = field_ast.name.value |
| 76 | +# field_def = type.fields[field_name] |
| 77 | +# field_base_type = get_base_type(field_def.type) |
| 78 | +# if not isinstance(field_base_type, GraphQLObjectType): |
| 79 | +# continue |
| 80 | +# field_fragments[field_name] = generate_fragment(field_base_type, field_ast.selection_set.selections) |
81 | 81 |
|
82 |
| - return Fragment( |
83 |
| - type, |
84 |
| - field_asts, |
85 |
| - field_fragments, |
86 |
| - execute_serially=execute_serially |
87 |
| - ) |
| 82 | +# return Fragment( |
| 83 | +# type, |
| 84 | +# field_asts, |
| 85 | +# field_fragments, |
| 86 | +# execute_serially=execute_serially |
| 87 | +# ) |
88 | 88 |
|
89 | 89 |
|
90 |
| -def build_query(schema, document_ast): |
91 |
| - static_context = QueryBuilder(schema, document_ast) |
| 90 | +# def build_query(schema, document_ast): |
| 91 | +# static_context = QueryBuilder(schema, document_ast) |
0 commit comments