简体   繁体   中英

How to set request header to access Hasura GraphQL Heroku server in Flutter?

I am not able to send a POST request to my Hasura endpoint from my Flutter client and even from POSTMAN.

Here is my current error:

{"errors":[{"extensions":{"path":"$","code":"invalid-json"},"message":"Error in $: not enough input"}]}

I added endpoint my_endpoint/v1/graphql and HASURA_GRAPHQL_ADMIN_SECRET which I set in Heroku dashboard. ( This value now shows up on my deployed herokuapp console)

My client is using ferry-graphql like this

Client initClient(String url, String secret) {
  final link = HttpLink(
    url,
    defaultHeaders: {
      'x-hasura-admin-secret': secret,
    },
  );
  final cache = Cache();

  final client = Client(
    link: link,
    cache: cache,
  );
  return client;
}

I am not sure what else I should add for my client request header to access hasura.

If i understand your question... you seems to be sending POST request without any Query or Mutation or Subscription being sent in payload..? you should send a valid GraphQL Query to fetch any response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM