Skip to content

Commit 2cc3a7f

Browse files
committed
Fix mcc_island.schema and API schema having different definition for deprecated directive
1 parent a5e2f0f commit 2cc3a7f

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

‎mcc_api/island/__init__.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from .types import *
77
from gql import Client
88
from gql.transport.requests import RequestsHTTPTransport
9-
from graphql import GraphQLSchema, specified_directives
9+
from graphql import (
10+
GraphQLSchema, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLSpecifiedByDirective, GraphQLOneOfDirective
11+
)
1012
import typing as t
1113

1214

@@ -16,7 +18,10 @@
1618

1719
schema = GraphQLSchema(
1820
query=query_type,
19-
directives=[*specified_directives, one_of_directive, spectaql_directive],
21+
directives=[
22+
GraphQLIncludeDirective, GraphQLSkipDirective, deprecated_directive,
23+
GraphQLSpecifiedByDirective, GraphQLOneOfDirective, spectaql_directive
24+
],
2025
types=[
2126
asset_quantity_type,
2227
auction_listing_type,

‎mcc_api/island/directives.py‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
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+
)
35

46

57
__all__ = [
6-
"one_of_directive", "spectaql_directive"
8+
"deprecated_directive", "spectaql_directive"
79
]
810

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+
]
1628
)
1729

1830
# Despite being an internal directive, defining @spectaql means that no breaking changes

0 commit comments

Comments
 (0)