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

CJS build isn't consumable

matthewlilley opened this issue · comments

I created a minimal reproduction to demonstrate the issue with a CJS build and consuming it.

https://github.com/matthewlilley/graphclient-cjs

Screenshot_86

Have you tried the same query on the actual GraphQL API?

@ardatan Yes. If you run pnpm dev and run it on the local graphql server it will work. It does this when you build CJS and try to consume it. ESM builds fail completely too.

@matthewlilley I mean did you try the same query on https://api.thegraph.com/subgraphs/name/sushiswap/exchange?

@ardatan The exact query is using prefix and autopagination, but a vanilla version can be seen working here:

https://thegraph.com/hosted-service/subgraph/sushiswap/exchange

@ardatan Ah, so this shows when "first" > 1000, and "first" is passed through the SDK.

Screenshot_87

If I set $first = 1001 in the query itself, I see the full error message "The first argument must be between 0 and 1000, but is 1001"

Screenshot_88

@ardatan this brings me back to the original issue, which is that pagination doesn't work when you build with:

graphclient build --fileType json

and when you do graphclient build --fileType js, it fails completely

@ardatan I did a little more digging and think I found the cause. If you don't explicitly set skip: 0 when using the SDK, it will fail to trigger autopagination. I updated the repro I shared earlier to demonstrate.

Screenshot_90

I've created seperate issues for the two new discoveries here and will close this for now