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.

graphql-modules-preset doesn't obey enumsAsTypes and doesn't generate per-module Resolvers types for enum internal values

See original GitHub issue

Describe the bug When using the graphql-modules preset it always generates enum as TypeScript type instead of enum, even if you specify enumsAsTypes: false (which is the default anyway). Also it doesn’t generate per-module Resolvers types for enum internal values (it does in the complete schema types).

To Reproduce This is the repro: https://github.com/darkbasic/gqlmodules-codegen-enumastypes-repro This is the codesandbox url: https://codesandbox.io/s/github/darkbasic/gqlmodules-codegen-enumastypes-repro

About the enums Resolvers types as you can see they get generated in the complete schema types: https://github.com/darkbasic/gqlmodules-codegen-enumastypes-repro/blob/master/src/types/graphql.ts#L133 While they don’t in the per-module schema types: https://github.com/darkbasic/gqlmodules-codegen-enumastypes-repro/blob/master/src/modules/A/types/module-types.ts#L19 https://github.com/darkbasic/gqlmodules-codegen-enumastypes-repro/blob/master/src/modules/B/types/module-types.ts Module B doesn’t even have a Resolvers type because I didn’t add a dummy Query to it.

About the enumsAsTypes issue just look here: https://github.com/darkbasic/gqlmodules-codegen-enumastypes-repro/blob/master/src/types/graphql.ts#L21 As you can see it clearly doesn’t obey enumsAsTypes: false. If you comment out the graphql-modules preset it will work as expected.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jaredgorskicommented, Feb 15, 2022

@dotansimha,

Are there any plans to fix this (specifically, per-module resolver types with enums)? I think this issue is actually rather problematic since most any reasonably useful project will use enums and most any large project would likely find graphql-modules-preset useful were it not for this issue. I’m finding myself removing the preset just because I want to define my enums in my module resolvers, but then I lose module-specific types.

Would love to know about any updates on this front. Thanks!

0reactions
jaredgorskicommented, Feb 16, 2022

@ardatan 😅 Well hey I just might, got a few things on my plate right now but let me take a deeper look when I get a breath.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't custom value of graphql enum - Stack Overflow
The internal values you specify for a GraphQL enum are just that -- internal. This is stated in the documentation: These don't change...
Read more >
Unions and Enums | NestJS - A progressive Node.js framework
Sometimes a backend forces a different value for an enum internally than in the public API. In this example the API contains RED...
Read more >
What you need to know about GraphQL enums
Learn how GraphQL enums can help you build more robust and discoverable APIs, create simple interfaces, maintain slim resolvers, and more.
Read more >
Build Enumerations of Constants With Python's Enum
Python doesn't have an enum data type as part of its syntax. ... Ensuring constant values that can't be changed during the code's...
Read more >
Custom Scalars and Enums – GraphQL Tools
Add custom scalar and enum types to your graphql-tools generated ... Enumerations are similar to custom scalars, but their values can only ...
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