Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Meemaw opened this issue Apr 27, 2023 · 1 comment
Open

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

Meemaw opened this issue Apr 27, 2023 · 1 comment

Comments

@Meemaw
Copy link

Meemaw commented Apr 27, 2023

This fails:

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

But this works:

@key(fields: "id")
@shareable
class X:
   pass
@erikwrede
Copy link
Member

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? ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants