How to setup Hasura CLI?

787 Views Asked by At

I installed Hasura CLI and I want to send data on my Hasura cloud project. I tried different ways to launch Hasura console but I don't find the good way to launch it. Every time I have the same error and I don't know how to solve it.

You can see my Hasura CLI config file in my project and the error.

ERRO connecting to graphql-engine server failed
INFO possible reasons:
INFO 1) Provided root endpoint of graphql-engine server is wrong. Verify endpoint key in config.yaml or/and value of --endpoint flag
INFO 2) Endpoint should NOT be your GraphQL API, ie endpoint is NOT https://hasura-cloud-app.io/v1/graphql it should be: https://hasura-cloud-app.io
INFO 3) Server might be unhealthy and is not running/accepting API requests
INFO 4) Admin secret is not correct/set
INFO FATA[0002] making http request failed: Get "http://localhost:8080/healthz": dial tcp [::1]:8080: connect: connection refused

HasuraCLI error

ConfigFile Hasura

2

There are 2 best solutions below

1
On

I Had two versions of hasura-cli, one installed with curl and one installed with npm.

I resolve the problem by removing all the version and installing the hasura-cli with npm and restarting the system

1
On

resolved :

When we use apollo client, we need to set the header in the client like this :


const client = new ApolloClient({
  uri: "https://yourapp.hasura.app/v1/graphql",
  cache: new InMemoryCache(),
  headers: {
    "content-type": "application/json",
    "x-hasura-admin-secret":
      "",
  },
});

this fix my problem