|
1 | 1 | from .types import spectaqloption_type |
2 | | -from graphql import DirectiveLocation, GraphQLArgument, GraphQLDirective, GraphQLList |
| 2 | +from graphql import ( |
| 3 | + DEFAULT_DEPRECATION_REASON, DirectiveLocation, GraphQLArgument, GraphQLDirective, GraphQLList, GraphQLString |
| 4 | +) |
3 | 5 |
|
4 | 6 |
|
5 | 7 | __all__ = [ |
6 | | - "one_of_directive", "spectaql_directive" |
| 8 | + "deprecated_directive", "spectaql_directive" |
7 | 9 | ] |
8 | 10 |
|
9 | | -# oneOf is not one of the directives defined by the GraphQL specification, and thus |
10 | | -# needs to be defined in order to avoid breaking changed being found when comparing |
11 | | -# this schema to that available from the API itself. |
12 | | -one_of_directive = GraphQLDirective( |
13 | | - name="oneOf", |
14 | | - description="Indicates an Input Object is a OneOf Input Object.", |
15 | | - locations=[DirectiveLocation.INPUT_OBJECT] |
| 11 | +# The locations defined by the graphql module's GraphQLDeprecatedDirective do not match those |
| 12 | +# defined by the API's schema, so we need this version to prevent breaking changes being found. |
| 13 | +deprecated_directive = GraphQLDirective( |
| 14 | + name="deprecated", |
| 15 | + description="The reason for the deprecation", |
| 16 | + args={ |
| 17 | + "reason": GraphQLArgument( |
| 18 | + GraphQLString, |
| 19 | + default_value=DEFAULT_DEPRECATION_REASON |
| 20 | + ) |
| 21 | + }, |
| 22 | + locations=[ |
| 23 | + DirectiveLocation.FIELD_DEFINITION, |
| 24 | + DirectiveLocation.ARGUMENT_DEFINITION, |
| 25 | + DirectiveLocation.ENUM_VALUE, |
| 26 | + DirectiveLocation.INPUT_FIELD_DEFINITION |
| 27 | + ] |
16 | 28 | ) |
17 | 29 |
|
18 | 30 | # Despite being an internal directive, defining @spectaql means that no breaking changes |
|
0 commit comments