Is your feature request related to a problem? Please describe.
Different backends require API token to passed with different pre parameters currently
Map<String, String> get headers => {
'Authorization': 'Bearer $apiToken',
'Content-Type': 'application/json',
};
the authorization header is fixed no alternative is possible, for example, I want the header to look like
"Authorization: JWT <your_token>"
Describe alternatives you've considered
The client API token could be
'Authorization': '$apiToken',
so that we can add any additional statement according to our requirement, but this should be backward compatible.
Or something like
Authorization: <type> <credentials>
Fix is in PR #36
@HofmannZ any progress?
@HofmannZ Looking forward to PR #36 as I too need to have more control over the headers for AWS AppSync.
I am testing out your link-1 branch, is that working for the http-link? I am accessing the GraphQL client outside of a widget.
If so, could you post some basic example code? I have tried to pass in the HttpLink object to the GraphqlClient, but get an error when trying to create the HttpLink object "type 'Link' is not a subtype of type 'HttpLink'" So I suspect I am doing something wrong.
@vmwsree, @endigo & @jeprojects fixed in #36.
To try it out use version 1.0.0-alpha.3 of this package.
@HofmannZ I'm trying appsync integration. Did you get that to work? If so, can you post how you passed auth to the client? Thank you.
how can I add authentication header in graphql-client api??
@Gitutsav it is actually quite easy and flexible. You could set your own http/Client implementation into the HttpLink constructor fetch parameter.
For our project I implemented bearer authentication with token refreshment in this client. You can intercept all the requests and modify them, add headers, query parameters, all you need.
But if you only need to set headers, just using them directly in the HttpLink constructor is enough.
@Gitutsav I think the easiest way would be to use the auth link or create a custom auth link.
@wwwdata I think it would be way easier to create your own link see #173.
Thanks sir
On Sun, Feb 17, 2019, 8:54 PM Zino Hofmann notifications@github.com wrote:
@Gitutsav https://github.com/Gitutsav I think the easiest way would be
to use the auth link or create a custom auth link.@wwwdata https://github.com/wwwdata I think it would be way easier to
create your own link see #173
https://github.com/zino-app/graphql-flutter/issues/173.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/zino-app/graphql-flutter/issues/53#issuecomment-464470085,
or mute the thread
https://github.com/notifications/unsubscribe-auth/An1rbND2dp3nyvWapXZ5E6m4c-qSia7nks5vOXQ9gaJpZM4VvijY
.
@HofmannZ Not sure where else to put this, but how would you create a custom Link that would listen for the responses and chain a request if needed? So if I try to make a mutation but my authentication token is expired, how can I check the graphql response for the authentication error, refresh my token, then retry my mutation?
Most helpful comment
@HofmannZ Not sure where else to put this, but how would you create a custom Link that would listen for the responses and chain a request if needed? So if I try to make a mutation but my authentication token is expired, how can I check the graphql response for the authentication error, refresh my token, then retry my mutation?