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)

Most upvoted comments

Hi, import isn’t working for enum values like import { Product, SortOrder } from "graphql-let/__generated__/__types__"; is working until i use SortOrder.Desc as a value.

Maybe graphql-let/__generated__/__types__ could have an index.js file that exports the enums as well as the .d.ts files?

Add the line in .graphql-let.yml

cacheDir: src/graphql/.cache

Now all cached typescript enum files will be stored in src/graphql/.cache, and can be imported from here import { Example_Enum } from "src/grahql/.cache/__types__" don’t forget to add src/graphql/.cache in .gitignore

Thank 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 around graphql-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/@types after running codegen script. You can also setup alias for graphql types like :

"paths": {
    "@graphql-types@": ["node_modules/@types/graphql-let/__generated__/__types__"],
},

then use it like so :

import { QueryResolvers, MutationResolvers } from '@graphql-types@';

@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.