Skip to content

Update documentation to clarify that enum keys are what are passed in/out of resolvers.  #1714

@dwjohnston

Description

@dwjohnston

Describe the issue

An issue I have just experience is when I have an enum like:

enum Status = {
    PENDING = "P", 
    COMPLETE = "C"
}

registerEnumType(Status, {name: "Status}); 

Where I'm hoping to use a query argument like : {status: 'P'}.

That this won't work, GraphQL will resolve the on the keys of the enum, not the values.

There are github issues that similarly reference this issue:

#741
#1521

and this section of the documentation is linked:

https://typegraphql.com/docs/enums.html#interoperability

However, what this doesn't communicate is that the use of enums expects the enum keys to be passed into resolvers/returned from resolvers. This pitfall should be more strongly emphasised.

Are you able to make a PR that fix this?

Sure.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions