Closed JosXa closed 4 years ago
Hi @JosXa, thanks for reporting!
Ideally in GatsbyJS, the actual behavior is always just a string and only the type information is actually needed. So, I think === 'InsiderBuild'
is enough for it, or do I miss something here.
Can you share the example of schema customization that generates this enum type? I will test it and change the generated result to be const enum.
Providing code to be used at runtime is not the goal of this project. So, this will be prevented in the next version.
But please feel free to reopen this if you have case actually need this. :)
The plugin generates the following code:
for this schema (introspection.json):
and I am having troubles accessing the enum values, most likely due to global declaration namespaces being compiled away during the build process (as a result of https://github.com/cometkim/gatsby-plugin-typegen/pull/47):
... results in:
Uncaught ReferenceError: GatsbyTypes is not defined
(only at runtime).The whole purpose of Enum types is to be able to do type-safe comparisons, so not being able to import them isn't helpful. Maybe I'm missing something and that is indeed possible, but I wouldn't know how.
But I also see that exporting this member from the global declarations file might go against the philosophy of that file, so I'm suggesting to maybe also generate a second file with all the importable constants such as the enums?