forked from graphql-python/graphene-federation
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
538 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
directive @composeDirective(name: String!) repeatable on SCHEMA | ||
directive @extends on OBJECT | INTERFACE | ||
directive @external on OBJECT | FIELD_DEFINITION | ||
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||
directive @inaccessible on | ||
| FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| UNION | ||
| ENUM | ||
| ENUM_VALUE | ||
| SCALAR | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
| ARGUMENT_DEFINITION | ||
directive @interfaceObject on OBJECT | ||
directive @override(from: String!) on FIELD_DEFINITION | ||
directive @provides(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @requires(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @shareable repeatable on FIELD_DEFINITION | OBJECT | ||
directive @tag(name: String!) repeatable on | ||
| FIELD_DEFINITION | ||
| INTERFACE | ||
| OBJECT | ||
| UNION | ||
| ARGUMENT_DEFINITION | ||
| SCALAR | ||
| ENUM | ||
| ENUM_VALUE | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
scalar FieldSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
directive @composeDirective(name: String!) repeatable on SCHEMA | ||
directive @extends on OBJECT | INTERFACE | ||
directive @external on OBJECT | FIELD_DEFINITION | ||
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||
directive @inaccessible on | ||
| FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| UNION | ||
| ENUM | ||
| ENUM_VALUE | ||
| SCALAR | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
| ARGUMENT_DEFINITION | ||
directive @interfaceObject on OBJECT | ||
directive @override(from: String!) on FIELD_DEFINITION | ||
directive @provides(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @requires(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @shareable repeatable on FIELD_DEFINITION | OBJECT | ||
directive @tag(name: String!) repeatable on | ||
| FIELD_DEFINITION | ||
| INTERFACE | ||
| OBJECT | ||
| UNION | ||
| ARGUMENT_DEFINITION | ||
| SCALAR | ||
| ENUM | ||
| ENUM_VALUE | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
directive @authenticated on | ||
FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| SCALAR | ||
| ENUM | ||
directive @requiresScopes(scopes: [[Scope!]!]!) on | ||
FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| SCALAR | ||
| ENUM | ||
scalar Scope | ||
scalar FieldSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
directive @composeDirective(name: String!) repeatable on SCHEMA | ||
directive @extends on OBJECT | INTERFACE | ||
directive @external on OBJECT | FIELD_DEFINITION | ||
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||
directive @inaccessible on | ||
| FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| UNION | ||
| ENUM | ||
| ENUM_VALUE | ||
| SCALAR | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
| ARGUMENT_DEFINITION | ||
directive @interfaceObject on OBJECT | ||
directive @override(from: String!) on FIELD_DEFINITION | ||
directive @provides(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @requires(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @shareable repeatable on FIELD_DEFINITION | OBJECT | ||
directive @tag(name: String!) repeatable on | ||
| FIELD_DEFINITION | ||
| INTERFACE | ||
| OBJECT | ||
| UNION | ||
| ARGUMENT_DEFINITION | ||
| SCALAR | ||
| ENUM | ||
| ENUM_VALUE | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
directive @authenticated on | ||
FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| SCALAR | ||
| ENUM | ||
directive @requiresScopes(scopes: [[Scope!]!]!) on | ||
FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| SCALAR | ||
| ENUM | ||
directive @policy(policies: [[federation__Policy!]!]!) on | ||
| FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| SCALAR | ||
| ENUM | ||
scalar federation__Policy | ||
scalar Scope | ||
scalar FieldSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from graphql import GraphQLDirective | ||
|
||
from .v2_3 import get_directives as get_directives_v2_3 | ||
|
||
|
||
# No Change, Added Subscription Support | ||
def get_directives() -> dict[str, GraphQLDirective]: | ||
return get_directives_v2_3() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from graphene_directives import CustomDirective, DirectiveLocation | ||
from graphql import GraphQLArgument, GraphQLDirective, GraphQLList, GraphQLNonNull | ||
|
||
from .v2_4 import get_directives as get_directives_v2_4 | ||
from ..scalars import Scope | ||
|
||
authenticated_directive = CustomDirective( | ||
name="authenticated", | ||
locations=[ | ||
DirectiveLocation.FIELD_DEFINITION, | ||
DirectiveLocation.OBJECT, | ||
DirectiveLocation.INTERFACE, | ||
DirectiveLocation.SCALAR, | ||
DirectiveLocation.ENUM, | ||
], | ||
description="Federation @authenticated directive", | ||
add_definition_to_schema=False, | ||
) | ||
|
||
requires_scope_directive = CustomDirective( | ||
name="requiresScopes", | ||
locations=[ | ||
DirectiveLocation.FIELD_DEFINITION, | ||
DirectiveLocation.OBJECT, | ||
DirectiveLocation.INTERFACE, | ||
DirectiveLocation.SCALAR, | ||
DirectiveLocation.ENUM, | ||
], | ||
args={ | ||
"scopes": GraphQLArgument( | ||
GraphQLNonNull( | ||
GraphQLList(GraphQLNonNull(GraphQLList(GraphQLNonNull(Scope)))) | ||
) | ||
), | ||
}, | ||
description="Federation @requiresScopes directive", | ||
add_definition_to_schema=False, | ||
) | ||
|
||
|
||
# No Change, Added Subscription Support | ||
def get_directives() -> dict[str, GraphQLDirective]: | ||
directives = get_directives_v2_4() | ||
directives.update( | ||
{ | ||
directive.name: directive | ||
for directive in [authenticated_directive, requires_scope_directive] | ||
} | ||
) | ||
return directives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from graphene_directives import CustomDirective, DirectiveLocation | ||
from graphql import GraphQLArgument, GraphQLDirective, GraphQLList, GraphQLNonNull | ||
|
||
from .v2_5 import get_directives as get_directives_v2_5 | ||
from ..scalars import FederationPolicy | ||
|
||
policy_directive = CustomDirective( | ||
name="policy", | ||
locations=[ | ||
DirectiveLocation.FIELD_DEFINITION, | ||
DirectiveLocation.OBJECT, | ||
DirectiveLocation.INTERFACE, | ||
DirectiveLocation.SCALAR, | ||
DirectiveLocation.ENUM, | ||
], | ||
args={ | ||
"policies": GraphQLArgument( | ||
GraphQLNonNull( | ||
GraphQLList( | ||
GraphQLNonNull(GraphQLList(GraphQLNonNull(FederationPolicy))) | ||
) | ||
) | ||
), | ||
}, | ||
description="Federation @policy directive", | ||
add_definition_to_schema=False, | ||
) | ||
|
||
|
||
# No Change, Added Subscription Support | ||
def get_directives() -> dict[str, GraphQLDirective]: | ||
directives = get_directives_v2_5() | ||
directives.update({directive.name: directive for directive in [policy_directive]}) | ||
return directives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
from .authenticated import authenticated | ||
from .extends import extends | ||
from .external import external | ||
from .inaccessible import inaccessible | ||
from .interface_object import interface_object | ||
from .key import key | ||
from .override import override | ||
from .policy import policy | ||
from .provides import provides | ||
from .requires import requires | ||
from .requires_scopes import requires_scope | ||
from .shareable import shareable | ||
from .tag import tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Any, Callable | ||
|
||
from graphene_directives import directive_decorator | ||
|
||
from .utils import is_non_field | ||
from ..apollo_versions import FederationVersion, LATEST_VERSION, get_directive_from_name | ||
|
||
|
||
def authenticated( | ||
field: Any = None, | ||
*, | ||
federation_version: FederationVersion = LATEST_VERSION, | ||
) -> Callable: | ||
directive = get_directive_from_name( | ||
"authenticated", federation_version=federation_version | ||
) | ||
decorator = directive_decorator(directive) | ||
return ( | ||
decorator(field=None)(field) if is_non_field(field) else decorator(field=field) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Any, Callable | ||
|
||
from graphene_directives import directive_decorator | ||
|
||
from .utils import is_non_field | ||
from ..apollo_versions import FederationVersion, LATEST_VERSION, get_directive_from_name | ||
|
||
|
||
def policy( | ||
field: Any = None, | ||
*, | ||
policies: list[list[str]], | ||
federation_version: FederationVersion = LATEST_VERSION, | ||
) -> Callable: | ||
directive = get_directive_from_name("policy", federation_version=federation_version) | ||
decorator = directive_decorator(directive) | ||
return ( | ||
decorator(field=None, policies=policies)(field) | ||
if is_non_field(field) | ||
else decorator(field=field, policies=policies) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import Any, Callable | ||
|
||
from graphene_directives import directive_decorator | ||
|
||
from .utils import is_non_field | ||
from ..apollo_versions import FederationVersion, LATEST_VERSION, get_directive_from_name | ||
|
||
|
||
def requires_scope( | ||
field: Any = None, | ||
*, | ||
scopes: list[list[str]], | ||
federation_version: FederationVersion = LATEST_VERSION, | ||
) -> Callable: | ||
directive = get_directive_from_name( | ||
"requiresScopes", federation_version=federation_version | ||
) | ||
decorator = directive_decorator(directive) | ||
return ( | ||
decorator(field=None, scopes=scopes)(field) | ||
if is_non_field(field) | ||
else decorator(field=field, scopes=scopes) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from ._any import _Any | ||
from .federation_policy import FederationPolicy | ||
from .field_set_v1 import _FieldSet | ||
from .field_set_v2 import FieldSet | ||
from .link_import import link_import | ||
from .link_purpose import link_purpose | ||
from .scope import Scope |
Oops, something went wrong.