Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #23 from preply/provides
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
erebus1 authored Nov 21, 2019
2 parents d99613d + 995e10a commit 8991d59
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# graphene-federation
Federation support for graphene

Build: [![CircleCI](https://circleci.com/gh/preply/graphene-federation.svg?style=svg)](https://circleci.com/gh/erebus1/graphene-federation)
Build: [![CircleCI](https://circleci.com/gh/preply/graphene-federation.svg?style=svg)](https://circleci.com/gh/preply/graphene-federation)


Federation specs implementation on top of Python graphene lib
Expand Down Expand Up @@ -100,7 +100,7 @@ For more details see [examples](examples/)

Or better check [integration_tests](integration_tests/)

Also cool [example](https://github.com/erebus1/graphene-federation/issues/1) of integration with Mongoengine
Also cool [example](https://github.com/preply/graphene-federation/issues/1) of integration with Mongoengine


### For contribution:
Expand Down
3 changes: 2 additions & 1 deletion graphene_federation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .main import key, build_schema
from .main import build_schema
from .entity import key
from .extend import extend, external, requires
14 changes: 14 additions & 0 deletions graphene_federation/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,17 @@ def resolve_entities(parent, info, representations):
return entities

return EntityQuery


def key(fields: str):
def decorator(Type):
register_entity(Type.__name__, Type)

existing = getattr(Type, "_sdl", "")

key_sdl = f'@key(fields: "{fields}")'
updated = f"{key_sdl} {existing}" if existing else key_sdl

setattr(Type, '_sdl', updated)
return Type
return decorator
14 changes: 0 additions & 14 deletions graphene_federation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,3 @@ def _get_query(schema, query_cls=None):
def build_schema(query=None, mutation=None, **kwargs):
schema = graphene.Schema(query=query, mutation=mutation, **kwargs)
return graphene.Schema(query=_get_query(schema, query), mutation=mutation, **kwargs)


def key(fields: str):
def decorator(Type):
register_entity(Type.__name__, Type)

existing = getattr(Type, "_sdl", "")

key_sdl = f'@key(fields: "{fields}")'
updated = f"{key_sdl} {existing}" if existing else key_sdl

setattr(Type, '_sdl', updated)
return Type
return decorator

0 comments on commit 8991d59

Please sign in to comment.