question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unbound enum values are None when used in arguments

See original GitHub issue

When used as a mutation input, enum parameter should be str, but actually is None.

def test_executing_mutation_takes_enum():
    type_defs = """
        type Query {
            _: String
        }

        type Mutation {
            eat(meal: Meal!): Int!
        }

        enum Meal {
            SPAM
        }
    """

    mutation = MutationType()

    @mutation.field("eat")
    def resolve_eat(*_, meal):  # pylint: disable=unused-variable
        assert meal == "SPAM"
        return 42

    schema = make_executable_schema(type_defs, mutation)

    result = graphql_sync(schema, 'mutation { eat(meal: SPAM) }')
    assert result.errors is None
    assert result.data == {"eat": 42}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rafalpcommented, May 11, 2019

We’ve fixed this on master, but in meantime to release hotfix would using ariadne.EnumType to set those values explicitly in python:

meal = EnumType("Meal", {"SPAM": "SPAM"})

Thanks for report!

0reactions
emilmelnikovcommented, May 13, 2019

We’ve fixed this on master

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generic versions of enum.Enum? #535 - python/typing - GitHub
To me, it seems this could be solved by introducing a generic Enum type in typing, similar to Sequence[T] and the other generics...
Read more >
How to get random value of attribute of Enum on each iteration?
As others have said, the best way is to just make random() be a method on your enum class to make it clear...
Read more >
Enum HOWTO — Python 3.11.1 documentation
An Enum is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more...
Read more >
Why Swift Enums with Associated Values Cannot Have a Raw ...
First of all, you're not bound to use Integers for the value that is represented by a particular case. You can use Strings,...
Read more >
Build Enumerations of Constants With Python's Enum
You can change this initial value using the start argument. Note that defining the above enumerations with the class syntax will produce the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found