-
Notifications
You must be signed in to change notification settings - Fork 26
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
Are headers supported? #52
Comments
You can set a For example, import Ember from 'ember';
import Adapter from 'ember-graphql-adapter';
const { computed, get, inject: { service }} = Ember;
export default Adapter.extend({
currentUser: service(),
endpoint: 'https://api.github.com/graphql',
httpMethod: 'POST',
headers: computed('currentUser.oauthToken', function() {
let headers = {};
const authToken = get(this, 'currentUser.oauthToken');
if (authToken) {
headers['Authorization'] = authToken;
}
return headers;
})
}); or more simply, import Adapter from 'ember-graphql-adapter';
export default Adapter.extend({
endpoint: 'https://api.github.com/graphql',
httpMethod: 'POST',
headers: { 'Authorization': oauthToken }
}); |
Awesome! That works except that it urlencodes the request body to the server (also I need to set If I change line 260 of the let ajaxOpts = this.ajaxOptions(url, JSON.stringify({ query: compiledQuery })); Also, AFAIK I need to replace the |
It's already sending it as JSON: ember-graphql-adapter/addon/adapter.js Line 340 in 6deca9a
|
It was sending JSON, but it the data was urlencoded for some reason, not sure why. It might have something to do with jQuery. My need was really simple so I just made my own adaptor to get my data, so I'll close for now. Thanks for the help! |
I'm trying to access GitHub's GraphQL API and as far as I can tell from the code I can't set the
Authorization
header. Is that correct?The text was updated successfully, but these errors were encountered: