ensdomains / ensjs

ENS javascript library for contract interaction
MIT License
113 stars 46 forks source link

TypeError: imported.GraphQLClient is not a constructor #65

Closed baixiaoyu2997 closed 1 year ago

baixiaoyu2997 commented 1 year ago

issue file in node_modules/.pnpm/@ensdomains+ensjs@3.0.0-alpha.27_mcvdqz4zwuomkpehair733j7qa/node_modules/@ensdomains/ensjs/dist/esm/GqlManager.mjs

at :

var GqlManager = class {
  gql = () => null;
  client = null;
  setUrl = async (url) => {
    if (url) {
      const [imported, traverse, { visit, parse, print }] = await Promise.all([
        import("graphql-request"),
        import("traverse"),
        import("graphql/language")
      ]);
      this.client = new imported.GraphQLClient(url, {   // TypeError: imported.GraphQLClient is not a constructor
        requestMiddleware: requestMiddleware(visit, parse, print),
        responseMiddleware: responseMiddleware(traverse.default)
      });
      this.gql = imported.gql;
    } else {
      this.client = null;
      this.gql = () => null;
    }
  };
  request = (...arg) => this.client ? this.client.request(...arg) : null;
};

repo:

const provider = new ethers.providers.JsonRpcProvider('https://eth-goerli.g.alchemy.com/v2/xxxxxxxx')
  const ENSInstance = new ENS()
  await ENSInstance.setProvider(provider) // when i `setProvider` will show error
  ENSInstance.getName(address.value).then((res) => {
    console.log(res)
  })

and i hope u guys can add some demo, about how use v3 with goerli testnet

baixiaoyu2997 commented 1 year ago

ok, i follow the document ,use ensjs way, show this error . but , i just switch to ethers.js , it worked

TateB commented 1 year ago

do you have graphql-request installed? it's a peer dependency

baixiaoyu2997 commented 1 year ago

i think could be this , for now , close this issue

do you have graphql-request installed? it's a peer dependency