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

The graphql package is only a devDependency #12

Closed
jonaskello opened this issue Aug 17, 2018 · 4 comments
Closed

The graphql package is only a devDependency #12

jonaskello opened this issue Aug 17, 2018 · 4 comments

Comments

@jonaskello
Copy link
Member

The gql-cache package does not run any code from the graphql package, but it does use types from @types/graphql in order to express what types should be passed into it's functions.

So another package developed in typescript, lets call it foo wants to use gql-cache but has no need for the graphql package. However the foo package will not compile now becuase it will fail on the code that imports types from graphql since @types/graphql is not installed anywhwere for the foo package. You get an error like this:

node_modules/gql-cache/lib/denormalize.d.ts:1:26 - error TS2307: Cannot find module 'graphql'.

1 import * as GraphQL from "graphql";
@jonaskello
Copy link
Member Author

I can see two alternative solutions to this:

  1. Remove graphql and @types/graphql as depdenencies from gql-cache and instead declare those types as any.

  2. Make @types/graphql a peerDependency of gql-cache, thus forcing all packages that use it to install the types which will make them compile.

@jonaskello
Copy link
Member Author

According to these docs:

Packaging dependent declarations
If your type definitions depend on another package:

Don’t combine it with yours, keep each in their own file.
Don’t copy the declarations in your package either.
Do depend on the npm type declaration package if it doesn’t package its declaration files.

@jonaskello
Copy link
Member Author

According to this comment and this other comment made by a typescript member, we should put the @types packages as dependencies instead of devDependencies.

@jonaskello
Copy link
Member Author

So the solution I think would be to add @types/graphql as a regular dependency while graphql can still be a devDependency since we only use types and don't actually call anything inside the graphql package. But perhaps both should be a regular dependency to not confuse things too much.

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