graphql-let: Can't use Enum value after upgrading to v0.18.0 in a nextjs app
within a nextjs app after upgrading to v0.18.0 according to the migration guide i’m getting Can't resolve 'graphql-let/__generated__/__types__'
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 6
- Comments: 15 (1 by maintainers)
Hi, import isn’t working for enum values like
import { Product, SortOrder } from "graphql-let/__generated__/__types__";is working until i useSortOrder.Descas a value.Maybe
graphql-let/__generated__/__types__could have anindex.jsfile that exports the enums as well as the .d.ts files?Add the line in .graphql-let.yml
cacheDir: src/graphql/.cacheNow all cached typescript enum files will be stored in
src/graphql/.cache, and can be imported from hereimport { Example_Enum } from "src/grahql/.cache/__types__"don’t forget to addsrc/graphql/.cachein.gitignoreThank you @neamatmim and @prkagrawal for taking your time for this. I confirmed the behavior.
For a quick solution, please try
import { SortOrder } from "${cacheDir}/__types__". I checked it works locally.To someone more familiar with TypeScript than me: Can’t we import Enum values from
.d.ts? If so and no good way to achieve that, I need to rethink the spec aroundgraphql-let/__generated__/__types__.Hi, I also came across this same issue, you need to run codegen script before lint or build in your case. graphql-let directory is only generated in
node_modules/@typesafter running codegen script. You can also setup alias for graphql types like :then use it like so :
@piglovesyou thanks for your good work. I confirmed the quick solution is working and hope you’ll provide us a recommended solution for this use case.