|
1 | 1 | from typing import Union
|
2 | 2 |
|
3 |
| -from ..language import ( |
4 |
| - DocumentNode, |
5 |
| - Source, |
6 |
| - parse, |
7 |
| -) |
8 |
| -from ..type import ( |
9 |
| - GraphQLDeprecatedDirective, |
10 |
| - GraphQLIncludeDirective, |
11 |
| - GraphQLSchema, |
12 |
| - GraphQLSkipDirective, |
13 |
| - GraphQLSpecifiedByDirective, |
14 |
| -) |
| 3 | +from ..language import DocumentNode, Source, parse |
| 4 | +from ..type import GraphQLSchema, specified_directives |
15 | 5 | from .extend_schema import extend_schema_impl
|
16 | 6 |
|
17 | 7 | __all__ = [
|
@@ -74,14 +64,9 @@ def build_ast_schema(
|
74 | 64 |
|
75 | 65 | directives = schema_kwargs["directives"]
|
76 | 66 | # If specified directives were not explicitly declared, add them.
|
77 |
| - if not any(directive.name == "skip" for directive in directives): |
78 |
| - directives.append(GraphQLSkipDirective) |
79 |
| - if not any(directive.name == "include" for directive in directives): |
80 |
| - directives.append(GraphQLIncludeDirective) |
81 |
| - if not any(directive.name == "deprecated" for directive in directives): |
82 |
| - directives.append(GraphQLDeprecatedDirective) |
83 |
| - if not any(directive.name == "specifiedBy" for directive in directives): |
84 |
| - directives.append(GraphQLSpecifiedByDirective) |
| 67 | + for std_directive in specified_directives: |
| 68 | + if all(directive.name != std_directive.name for directive in directives): |
| 69 | + directives.append(std_directive) |
85 | 70 |
|
86 | 71 | return GraphQLSchema(**schema_kwargs)
|
87 | 72 |
|
|
0 commit comments