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

'chainName' does not exist in type 'MeshContext' | cross-chain-extension

vlad1chek opened this issue · comments

Hello there!
I found the bug in latest versions of @graphprotocol/client-cli and @graphprotocol/client-add-source-name. When I try to implement cross-chain query like in your example I can't build my project because I get typescript error:

Type '{ chainName: string; sushiswap: { Query: SushiswapTypes.QuerySdk; Mutation: SushiswapTypes.MutationSdk; Subscription: SushiswapTypes.SubscriptionSdk; }; [MESH_CONTEXT_SYMBOL]: true; pubsub: MeshPubSub; cache: KeyValueCache<...>; logger: Logger; }' is not assignable to type 'MeshContext'.
  Object literal may only specify known properties, and 'chainName' does not exist in type 'MeshContext'.

I did small investigation and found out that all works fine with old versions:

"@graphprotocol/client-add-source-name": "1.0.2",
"@graphprotocol/client-cli": "2.1.1",

Also, you can check the example of the error in codesandbox https://codesandbox.io/s/musing-zhukovsky-2mzu0f?file=/resolvers.ts
image

I have it, but it doesn't help. I checked types in .graphclient folder and the context indeed has chainName. But for some reason, this error still exists.

export type Context = {
      ["sushiswap"]: { Query: QuerySdk, Mutation: MutationSdk, Subscription: SubscriptionSdk },
      ["chainName"]: Scalars['ID']
    };

Codesandbox example also has this line in .graphclientrc.yml but the error persists.