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

environment variables not working

gigamesh opened this issue · comments

If I follow the instructions in the readme and specify an env var like this in .graphclientrc.yml:

sources:
  - name: farther
    handler:
      graphql:
        endpoint: https://api.studio.thegraph.com/query/{env.SUBGRAPH}/version/latest

and then start the process with the following script: SUBGRAPH=<subgraph-id> graphclient build

...the variable doesn't get injected. Does anyone know why?

Unless I'm misunderstanding something, thegraphclient build process has a bug. If I look at the generated code, I see:

...
    config: {
      endpoint: "https://api.studio.thegraph.com/query/{env.SUBGRAPH}/version/latest",
    },
...

If I change it to this, it works:

...
    config: {
      endpoint: `https://api.studio.thegraph.com/query/${process.env.SUBGRAPH}/version/latest`,
    },
...

for anyone else who lands here with the same problem, it works if you make .graphclientrc a javascript file, described here:

ardatan/graphql-mesh#5442 (comment)