nearform / graphql-hooks

🎣 Minimal hooks-first GraphQL client
Other
1.88k stars 90 forks source link

Graphql dependency doesn't make this a "tiny" bundle anymore #1177

Closed madshall closed 3 months ago

madshall commented 3 months ago

Package

graphql-hooks

Environment

Description

The latest version has a peer dependency on graphql package which is 40kb gzipped. It's 7 times this package's size. So in order to use this lightweight package we need to install 40kb additional dependencies. This destroys the whole idea of it.

Suggested solution (optional)

Make graphql an optional dependency or remove the feature that requires it.

carbonrobot commented 3 months ago

Consider using @no-co/graphql.web if this is all client side usage. This is what URQL uses under the covers.

simoneb commented 3 months ago

@marceloFerreira90 please take a look

marceloFerreira90 commented 3 months ago

The reason for the peerDependency of GraphQL is the use of TypedDocumentNode. The approach to fix this will be to replicate the way it was implemented in graphQL as it only has a dependency on DocumentNode which is available on @no-co/graphql.web

It could be a good issue for that package too.

simoneb commented 3 months ago

As discussed:

  1. let's switch to using @no-co/graphql.web
  2. implement TypedDocumentNode in our code, it's just an interface
  3. submit an issue to @no-co/graphql.web to ask to create that interface in there