-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
14881c1
commit 8985776
Showing
2 changed files
with
54 additions
and
0 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,52 @@ | ||
import graphene | ||
from graphene import ObjectType | ||
from graphql import graphql_sync | ||
|
||
from graphene_federation import build_schema, shareable, inaccessible | ||
|
||
|
||
def test_custom_enum(): | ||
class Episode(graphene.Enum): | ||
NEWHOPE = 4 | ||
EMPIRE = 5 | ||
JEDI = 6 | ||
|
||
@shareable | ||
class TestCustomEnum(graphene.ObjectType): | ||
test_shareable_scalar = shareable(Episode()) | ||
test_inaccessible_scalar = inaccessible(Episode()) | ||
|
||
class Query(ObjectType): | ||
test = Episode() | ||
test2 = graphene.List(TestCustomEnum, required=True) | ||
|
||
schema = build_schema( | ||
query=Query, enable_federation_2=True, types=(TestCustomEnum,) | ||
) | ||
query = """ | ||
query { | ||
_service { | ||
sdl | ||
} | ||
} | ||
""" | ||
result = graphql_sync(schema.graphql_schema, query) | ||
assert ( | ||
result.data["_service"]["sdl"].strip() | ||
== """extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@inaccessible", "@shareable"]) | ||
type TestCustomEnum @shareable { | ||
testShareableScalar: Episode @shareable | ||
testInaccessibleScalar: Episode @inaccessible | ||
} | ||
enum Episode { | ||
NEWHOPE | ||
EMPIRE | ||
JEDI | ||
} | ||
type Query { | ||
test: Episode | ||
test2: [TestCustomEnum]! | ||
}""" | ||
) |
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