graphprotocol / graph-client

The Graph library for building GraphQL-based dapps in a decentralized way.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Distributing an SDK

matthewlilley opened this issue · comments

Hey, we have a @sushiswap/graph-client package which we want to distribute.

Generating ESM with --fileType js onsistently fails with introspection errors on build.

Generating CJS with --fileType json works, but it requires me to include a bunch of dependencies to the package such as:

"@graphql-mesh/utils": "latest",
"@graphql-mesh/cache-localforage": "latest",
"@whatwg-node/fetch": "latest",
"@graphql-mesh/graphql": "latest",
"@graphql-mesh/merger-stitching": "latest",
"@graphql-mesh/http": "latest",
"@graphql-mesh/runtime": "latest",
"@graphql-mesh/store": "latest",
"@graphql-mesh/cross-helpers": "latest",

Unfortunately when we do this auto pagination stops working.

Woud you be able to provide some guidance on distributing?

Our graph-client package: https://github.com/sushiswap/sushiswap/tree/master/packages/graph-client

Our cli which consumes it: https://github.com/sushiswap/sushiswap/tree/master/packages/cli (in particular, the actions/maker command fails because it needs to paginate)

This maybe unrelated but...

If I build the CJS example in this repository it generates .js & .mjs

Screenshot_81

If I run the same command on @sushiswap/graph-client, it only generates .js and no .mjs

Screenshot_80

Running the ESM example in this repository:

Screenshot_82

I notice that @graph-mesh/utils is imported 4 times in the CJS build too.

Screenshot_84