MichalLytek / MichalLytek/type-graphql

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

Open
#1,714 0 comments 0 reactions 0 assignees View on GitHub
Community :family_man_girl: Documentation :book:
Dominant language
TypeScript
Stars
8.1k
Forks
672
PR merge metrics
No merged PRs in 30d

Description

**Describe the issue**

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

```typescript
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:

https://github.com/MichalLytek/type-graphql/issues/741
https://github.com/MichalLytek/type-graphql/issues/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.

Contributor guide

Open the contributing guide

Research direction

Read the enums documentation's Interoperability section linked in the issue, then compare its explanation with the reported enum example. Update the documentation to clearly state that enum keys, rather than their values, are passed into and returned from resolvers; the page should explicitly cover the `{status: 'P'}` pitfall.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.