nearform / graphql-hooks

🎣 Minimal hooks-first GraphQL client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

madshall opened this issue · comments

Package

graphql-hooks

Environment

  • graphql-hooks version: latest

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.

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

@marceloFerreira90 please take a look

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.

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