Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import ReactApolloRawPluginConfig under "moduleResolution": "node16" #513

Open
alexeyr-ci opened this issue Nov 24, 2023 · 2 comments

Comments

@alexeyr-ci
Copy link

Which packages are impacted by your issue?

@graphql-codegen/typescript-react-apollo

Describe the bug

import type { ReactApolloRawPluginConfig } from '@graphql-codegen/typescript-react-apollo/typings/config';

compiles under "moduleResolution": "node", but fails under node16 (or nodenext).

Should it be imported in a different way? Removing typings fails as well. I could just not import the type, but would prefer to have the type safety (e.g. it alerted me earlier that typescript-react-apollo doesn't yet support separate input and output types for scalars).

Your Example Website or App

https://github.com/alexeyr-ci/graphql-code-generator-issue-sandbox/tree/typescript-react-apollo-config-import

Steps to Reproduce the Bug or Issue

Run tsc --noEmit.

Expected behavior

As a user, I expected the codegen config to compile successfully, but it fails with

codegen.ts:2:49 - error TS2307: Cannot find module '@graphql-codegen/typescript-react-apollo/typings/config' or its corresponding type declarations.

2 import type { ReactApolloRawPluginConfig } from '@graphql-codegen/typescript-react-apollo/typings/config';
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Screenshots or Videos

No response

Platform

  • OS: WSL2
  • NodeJS: 18.17.0
  • graphql version: 16.6.0
  • @graphql-codegen/* version(s):
    "@graphql-codegen/cli": 4.0.1,
    "@graphql-codegen/typescript": 4.0.1,
    "@graphql-codegen/typescript-operations": 4.0.1,
    "@graphql-codegen/typescript-react-apollo": 4.1.0,

Codegen Config File

import { CodegenConfig } from "@graphql-codegen/cli";
import type { ReactApolloRawPluginConfig } from '@graphql-codegen/typescript-react-apollo/typings/config';

const apolloConfig: ReactApolloRawPluginConfig = {};

const config: CodegenConfig = {
  schema: "schema.graphql",
  documents: "document.graphql",
  generates: {
    "types.ts": { plugins: ["typescript", "typescript-operations"] },
  },
};

export default config;

Additional context

No response

@alexeyr-ci
Copy link
Author

A workaround which works but I'd prefer to avoid:

import type { ReactApolloVisitor } from '@graphql-codegen/typescript-react-apollo';

type ReactApolloRawPluginConfig = ReactApolloVisitor['rawConfig'];

(it can be similarly obtained from plugin).

@alexeyr-ci
Copy link
Author

Perhaps related: adaltas/node-csv#354.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant