-
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.
* Federation v2 support added * Minor fix in link * Minor fix in @provides * Minor fix in @keys * Revert patch in @keys * Remove Print * add override @OverRide to @link * fix @link * fix @link * fix @link * Test case passed * Add @key (multi) support * Fix Test Cases * Fix Test Cases * Fix Lint Error * Update README.md * Fix Lint Error * Multi fields support @extend * Federation v2 support added * Minor fix in link * Minor fix in @provides * Minor fix in @keys * Revert patch in @keys * Remove Print * add override @OverRide to @link * fix @link * fix @link * fix @link * Test case passed * Add @key (multi) support * Fix Test Cases * Fix Test Cases * Fix Lint Error * Update README.md * Fix Lint Error * Multi fields support @extend * Fix Lint error * mark PageInfo @Shareable * Refactor: @OverRide directive argument renamed to from_ * Add: resolvable argument to @key directive * WIP: Toggle for federation v2 * Fix: correct resolvable attribute of entity * Fix: correct entity set building Add: federation v2 arg to test cases * Fix: resolvable argument addition to schema * Refactor: Correct docstrings * Add: enable_federation_2 to examples * Add: test case for compound keys Refactor: Docstring and checks in inaccessible directive * Fix: Lint issues * Fix: Remove duplicated definition of User type in test_key * Add: Compound key validation * Add: test for compound keys * Docs: Correct known issues in readme as compound keys are now working * Fix: lint * Update graphene_federation/shareable.py fix documentation Co-authored-by: Patrick Arminio <[email protected]> * Update graphene_federation/inaccessible.py remove the usage of builtin Co-authored-by: Patrick Arminio <[email protected]> * Fix: Correct output comments in examples * Fix: Use graphene_type._meta.fields for getting valid fields in type * Fix: Add resolvable argument only for federation v2 * Refactor: Rename variable Type to type_ * Doc: Correct comment * Remove: unused _shareable list in shareable.py * Lint: service.py * Add: utility function get_attributed_fields * Add: tests for federation v1 * LInt: fix lint error * Fix: optimise imports * Change: implementation of utility function is_valid_compound_key optimised * Change: combined logic for adding _inaccessible attribute to fields and types * Change: Compound key validation logic using graphql core parse() * Fix: Auto camelcase field names if enabled in schema * Add: Advanced test cases for Compound keys * Lint test_key.py * Support @inaccessible on graphene Interface * Fix: Lint Error * Fix: Gateway Dockerfile build error * Add Support: @inaccessible & @Shareable to graphene.Union * Update: Dependencies, Dockerfile Fix: Lint Error Passed: Test Cases * Add: Test case for @Shareable & @inaccessible * Fix: Lint Error --------- Co-authored-by: Arun Suresh Kumar <[email protected]> Co-authored-by: Adarsh Divakaran <[email protected]> Co-authored-by: Patrick Arminio <[email protected]>
- Loading branch information
1 parent
a68d491
commit 8b5e1e7
Showing
44 changed files
with
3,439 additions
and
7,520 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
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,70 @@ | ||
import graphene | ||
|
||
from graphene_federation import inaccessible, external, provides, key, override, shareable | ||
|
||
from graphene_federation import build_schema | ||
|
||
|
||
@key(fields="x") | ||
class Position(graphene.ObjectType): | ||
x = graphene.Int(required=True) | ||
y = external(graphene.Int(required=True)) | ||
z = inaccessible(graphene.Int(required=True)) | ||
a = provides(graphene.Int(), fields="x") | ||
b = override(graphene.Int(required=True), from_="h") | ||
|
||
|
||
@inaccessible | ||
class ReviewInterface(graphene.Interface): | ||
interfaced_body = graphene.String(required=True) | ||
|
||
|
||
@inaccessible | ||
class Review(graphene.ObjectType): | ||
class Meta: | ||
interfaces = (ReviewInterface,) | ||
|
||
id = graphene.Int(required=True) | ||
body = graphene.String(required=True) | ||
|
||
|
||
@inaccessible | ||
class Human(graphene.ObjectType): | ||
name = graphene.String() | ||
born_in = graphene.String() | ||
|
||
|
||
@inaccessible | ||
class Droid(graphene.ObjectType): | ||
name = graphene.String() | ||
primary_function = graphene.String() | ||
|
||
|
||
@inaccessible | ||
class Starship(graphene.ObjectType): | ||
name = graphene.String() | ||
length = graphene.Int() | ||
|
||
|
||
@inaccessible | ||
class SearchResult(graphene.Union): | ||
class Meta: | ||
types = (Human, Droid, Starship) | ||
|
||
|
||
class Query(graphene.ObjectType): | ||
position = graphene.Field(Position) | ||
|
||
|
||
schema = build_schema(Query, enable_federation_2=True, types=(ReviewInterface, SearchResult, Review)) | ||
|
||
query = ''' | ||
query getSDL { | ||
_service { | ||
sdl | ||
} | ||
} | ||
''' | ||
result = schema.execute(query) | ||
print(result.data) | ||
# {'_service': {'sdl': 'extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@external", "@key", "@override", "@provides", "@inaccessible"])\ntype Query {\n position: Position\n}\n\ntype Position @key(fields: "x") {\n x: Int!\n y: Int! @external\n z: Int! @inaccessible\n a: Int @provides(fields: "x")\n b: Int! @override(from: "h")\n}'}} |
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,28 @@ | ||
import graphene | ||
|
||
from graphene_federation import build_schema, shareable, external, key, override, inaccessible | ||
|
||
|
||
@key(fields="id") | ||
class Product(graphene.ObjectType): | ||
id = graphene.ID(required=True) | ||
in_stock = override(graphene.Boolean(required=True), "Products") | ||
out_stock = inaccessible(graphene.Boolean(required=True)) | ||
|
||
|
||
class Query(graphene.ObjectType): | ||
position = graphene.Field(Product) | ||
|
||
|
||
schema = build_schema(Query, enable_federation_2=True) | ||
|
||
query = ''' | ||
query getSDL { | ||
_service { | ||
sdl | ||
} | ||
} | ||
''' | ||
result = schema.execute(query) | ||
print(result.data) | ||
# {'_service': {'sdl': 'extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key", "@override", "@inaccessible"])\ntype Query {\n position: Product\n}\n\ntype Product @key(fields: "id") {\n id: ID!\n inStock: Boolean! @override(from: "Products")\n outStock: Boolean! @inaccessible\n}'}} |
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,54 @@ | ||
import graphene | ||
from graphene import Interface | ||
|
||
from graphene_federation.shareable import shareable | ||
|
||
from graphene_federation import build_schema | ||
|
||
|
||
@shareable | ||
class Position(graphene.ObjectType): | ||
x = graphene.Int(required=True) | ||
y = shareable(graphene.Int(required=True)) | ||
|
||
|
||
@shareable | ||
class Human(graphene.ObjectType): | ||
name = graphene.String() | ||
born_in = graphene.String() | ||
|
||
|
||
@shareable | ||
class Droid(graphene.ObjectType): | ||
name = shareable(graphene.String()) | ||
primary_function = graphene.String() | ||
|
||
|
||
@shareable | ||
class Starship(graphene.ObjectType): | ||
name = graphene.String() | ||
length = shareable(graphene.Int()) | ||
|
||
|
||
@shareable | ||
class SearchResult(graphene.Union): | ||
class Meta: | ||
types = (Human, Droid, Starship) | ||
|
||
|
||
class Query(graphene.ObjectType): | ||
position = graphene.Field(Position) | ||
|
||
|
||
schema = build_schema(Query, enable_federation_2=True, types=(SearchResult,)) | ||
|
||
query = ''' | ||
query getSDL { | ||
_service { | ||
sdl | ||
} | ||
} | ||
''' | ||
result = schema.execute(query) | ||
print(result.data) | ||
# {'_service': {'sdl': 'extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@shareable"])\ntype Query {\n position: Position\n}\n\ntype Position @shareable {\n x: Int!\n y: Int! @shareable\n}'}} |
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,29 @@ | ||
import graphene | ||
|
||
from graphene_federation import build_schema, key, inaccessible, shareable | ||
from graphene_federation.tag import tag | ||
|
||
|
||
class Product(graphene.ObjectType): | ||
id = graphene.ID(required=True) | ||
in_stock = tag(graphene.Boolean(required=True), "Products") | ||
out_stock = shareable(graphene.Boolean(required=True)) | ||
is_listed = inaccessible(graphene.Boolean(required=True)) | ||
|
||
|
||
class Query(graphene.ObjectType): | ||
position = graphene.Field(Product) | ||
|
||
|
||
schema = build_schema(Query, enable_federation_2=True) | ||
|
||
query = ''' | ||
query getSDL { | ||
_service { | ||
sdl | ||
} | ||
} | ||
''' | ||
result = schema.execute(query) | ||
print(result.data) | ||
# {'_service': {'sdl': 'extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@inaccessible", "@shareable", "@tag"])\ntype Query {\n position: Product\n}\n\ntype Product {\n id: ID!\n inStock: Boolean! @tag(name: "Products")\n outStock: Boolean! @shareable\n isListed: Boolean! @inaccessible\n}'}} |
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,4 +1,9 @@ | ||
from .main import build_schema | ||
from .entity import key | ||
from .extend import extend, external, requires | ||
from .extend import extend | ||
from .external import external | ||
from .requires import requires | ||
from .shareable import shareable | ||
from .inaccessible import inaccessible | ||
from .provides import provides | ||
from .override import override |
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
Oops, something went wrong.