graphprotocol / graph-tooling

Monorepo for various tools used by subgraph developers.
https://thegraph.com/docs
Apache License 2.0
386 stars 206 forks source link

feat: add headers flag to the deploy command #905

Closed ppoliani closed 2 years ago

ppoliani commented 2 years ago

Allow a custom set of header to be used with the deploy command. This is useful for example if one wants to use a custom IPFS server e.g. Infura that requires a custom authentication logic.

For example

graph deploy subgraph \
--hdr "{\"authorization\": \"Basic MTIzOjQ1Ng==\"}" \
--ipfs https://ipfs.infura.io:5001 \
--node https://graph-json-rpc.example.com

Might be related to https://github.com/graphprotocol/graph-cli/issues/880

air3ijai commented 2 years ago

@ppoliani,

I'm checking graph deploy

yarn graph deploy subgraph-test subgraph.yaml \
  --version-label subgraph-test \
  --headers "{\"Authorization\": \"Basic password-to-base64\"}" \
  --ipfs https://ipfs.domain.tld \
  --node https://rinkeby.index.domain.tld
  Add file to IPFS build/templates/FixedRateExchange/FixedRateExchange.wasm
                .. QmQkhK3MqK31hAuwijHUoUqquDinXJWfiyZ28pD143NJX5
✔ Upload subgraph to IPFS

Build completed: QmTFpJT6sVSSXfw43LW8tmHh3uzKSqVAdQWFu3qBcRpnWR

✖ HTTP error deploying the subgraph 404
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

IPFS - :white_check_mark: Index - :x:

And a test to same endpoints with same headers using curl

curl --header "Authorization: Basic password-to-base64" https://ipfs.domain.tld
404 page not found

curl --header "Authorization: Basic password-to-base64" https://rinkeby.index.domain.tld
Used HTTP Method is not allowed. POST or OPTIONS is required

It means that authentication passed and all works correctly.