Skip to content

Fix checking enum values. #139

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

Closed
wants to merge 1 commit into from
Closed

Conversation

dpnova
Copy link

@dpnova dpnova commented Sep 18, 2017

This fixes graphql-python/graphene#547 for me. I'm not sure how it impacts native enums though.

@dpnova
Copy link
Author

dpnova commented Sep 19, 2017

There's a lot of broken tests here... I'll go digging, I'd appreciate anyone reviewing the change first though.

@lincolnq
Copy link

lincolnq commented Oct 18, 2017

This issue is also related to graphql-python/graphene#558.

I think the proposed PR isn't a great solution, as I think both the enum's value and the enum instance itself should be accepted. IMO, this test case should pass --

import graphene as gql

class Currency(gql.Enum):
    USD = 10
    GBP = 20

class Query(gql.ObjectType):
    currency1 = Currency()
    currency2 = Currency()
    def resolve_currency1(self, info):
        """Return a Currency value."""
        return 10
    def resolve_currency2(self, info):
        """Return a Currency instance."""
        return Currency.USD

schema = gql.Schema(query=Query)
assert schema.execute('{currency1}').data['currency1'] == 'USD' # works
assert schema.execute('{currency2}').data['currency2'] == 'USD' # fails, it's None

@dpnova
Copy link
Author

dpnova commented Oct 19, 2017

Yeah the PR just fixes my case. There's a bug here, we just need the best approach.

@dpnova
Copy link
Author

dpnova commented Oct 25, 2017

Use #140

@dpnova dpnova closed this Oct 25, 2017
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

Successfully merging this pull request may close these issues.

Enums don't seem to serialise properly
2 participants