Search code examples
typescriptgraphqlgraphql-codegen

GraphQL code generator - typescript-graphql-request generates sdk with invalid import


I'm trying to use typescript-graphql-request to generate an sdk. The generated file contains this import at the top

import * as Dom from 'graphql-request/dist/types.dom';

You can see an example if you go here and select "graphql-request typed SDK" in the select

This throws an error when I try to build my application

error TS2307: Cannot find module 'graphql-request/dist/types.dom' or its corresponding type declarations.

I have added graphql-request, but there is no /dist. vscode is giving me following suggestions: enter image description here

So my question is why does it try to import from /dist/types.dom? Why isn't it importing from 'graphql-request'. Am I supposed to build the graphql-request in node_modules first somehow?


Solution

  • Found this issue on gh

    Seems to be a problem with graphql-request 5.2.0, pinning it to 5.1.0 fixes the problem