3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GraphQLクライアントAltairでBearerTokenによる認証を動的に行う方法

Posted at

需要どの程度あるかわからんけど、日本語情報あんまなかったので、とりあえずメモをあげとく。

やり方

ヘッダが環境変数を参照できるようにする。
image.png

以下をPRE-REQUEST EDITORで設定する
(altair.helpers.requestのurl,パラメータ等は適宜合わせること)

const res = await altair.helpers.request(
  'POST',
  'http://test.api.site/auth/sign_in',
  { 
    params: {email: 'hoge@hoge.com', password: 'hogehoge' },
    observe: 'response'
  }
);
altair.helpers.setEnvironment('client', res.headers.get('client'));
altair.helpers.setEnvironment('uid', res.headers.get('uid'));
altair.helpers.setEnvironment('accessToken', res.headers.get('access-token'));

参考

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?