graphql-python / graphene-federation

Federation implementation for Graphene.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Applying @shareable after @key fails, but not vice versa

Meemaw opened this issue · comments

This fails:

@shareable
@key(fields: "id")
class X:
   pass

But this works:

@key(fields: "id")
@shareable
class X:
   pass

Hey, sorry for the late reply on this. I cannot reproduce your error with the following MWE:

from graphene_federation import shareable
from graphene_federation.entity import key
from graphene_federation.main import build_schema


def test_multiple_keys_share():
    @shareable
    @key(fields="identifier")
    class User(ObjectType):
        identifier = ID()
        email = String()

    class Query(ObjectType):
        user = Field(User)

    schema = build_schema(query=Query, enable_federation_2=True)
    print(str(schema))

If I instead use pass for the object type or don't extend the objecttype class, I get an exception regardless of the order of @key/@shared. But that's expected behavior. Can you share any additional context or a minimal example so I can have a closer look? ☺️