-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need more headers in AuthLink #173
Comments
You can write your own Link: typedef GetHeaders = Future<Map<String, String>> Function();
class CustomAuthLink extends Link {
CustomAuthLink({
this.getHeaders,
}) : super(
request: (Operation operation, [NextLink forward]) {
StreamController<FetchResult> controller;
Future<void> onListen() async {
try {
final Map<String, String> headers = await getHeaders();
operation.setContext(<String, Map<String, String>>{
'headers': headers
});
} catch (error) {
controller.addError(error);
}
await controller.addStream(forward(operation));
await controller.close();
}
controller = StreamController<FetchResult>(onListen: onListen);
return controller.stream;
},
);
GetHeaders getHeaders;
} And then you can implement it just as you would with the Hope that helps! |
Closing, seems revolved. |
@HofmannZ need to reopen this as the above CustomAuthLink's parameter signatures fails for 4.0.0 |
@5hanth we moved to a new link system, see https://github.com/zino-app/graphql-flutter/blob/beta/changelog-v3-v4.md#we-now-use-the-gql_link-system |
If people are having a hard time finding an example. https://github.com/gql-dart/gql/blob/master/links/gql_link/example/gql_link_example.dart |
You can create your own link (updated answer 2021) :
|
Our API service uses access-token and refresh token.
Here just one header: 'Authorization'
https://github.com/zino-app/graphql-flutter/blob/next/lib/src/link/auth/link_auth.dart#L21
We need 3 custom named headers.
for example:
Thanks.
The text was updated successfully, but these errors were encountered: