graph-client icon indicating copy to clipboard operation
graph-client copied to clipboard

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

Open vlad1chek opened this issue 1 year ago • 2 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

vlad1chek avatar Oct 11 '22 12:10 vlad1chek

You need to add this; https://github.com/graphprotocol/graph-client/blob/main/examples/cross-chain-extension/.graphclientrc.yml#L24

ardatan avatar Oct 11 '22 13:10 ardatan

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.

vlad1chek avatar Oct 11 '22 13:10 vlad1chek