Graphql-code-generator: [typescript-graphql-request] Importing not exported type

Created on 27 Jan 2021  路  2Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
typescript-graphql-request generates the following import

import { HeadersInit } from 'graphql-request/dist/types.dom';

HeadersInit is not exported from graphql-request

To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL schema:
type Foo {
  id: ID!
}

type Query {
  foo: Foo!
}
  1. My GraphQL operations:
query test {
  foo {
    id
  }
}
  1. My codegen.yml config file:
schema: ./schema.gql
documents: ./src/**/*.gql
overwrite: true
generates:
  ./src/index.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-graphql-request
    config:
      skipTypename: true
      namingConvention:
        transformUnderscore: true

Expected behavior
Generate TypeScript code without any errors.

Environment:

  • OS: Windows 10
{
    "@graphql-codegen/cli": "^1.20.1",
    "@graphql-codegen/introspection": "^1.18.1",
    "@graphql-codegen/typescript": "^1.20.2",
    "@graphql-codegen/typescript-graphql-request": "^3.0.1",
    "@graphql-codegen/typescript-operations": "^1.17.14",
    "graphql-request": "^3.4.0",
    "graphql": "^15.5.0"
}
  • NodeJS: 15

Additional context

It should be

import { RequestInit } from 'graphql-request/dist/types.dom';

The header type should be RequestInit['headers']. That is how the graphql-request defines.

https://github.com/prisma-labs/graphql-request/blob/a8d99f5cdbe57786ecb8d99c88175599608d2fc6/src/index.ts#L47

Most helpful comment

Workaround:

downgrade to "@graphql-codegen/typescript-graphql-request": "^3.0.0"

All 2 comments

Workaround:

downgrade to "@graphql-codegen/typescript-graphql-request": "^3.0.0"

downgrade to "@graphql-codegen/typescript-graphql-request": "3.0.0"
without the ^ to avoid automatically patching to 3.0.1

Was this page helpful?
0 / 5 - 0 ratings