Comments (4)
A little late to the party here, but here is what works for me with Hasura:
ajaxOptions: function (data) {
let opts = {
'dataType': 'json',
'data': data,
'type': this.httpMethod,
'context': this,
'contentType': 'application/json'
};
let headers = get(this, 'headers');
if (headers !== undefined) {
opts.beforeSend = function (xhr) {
Object.keys(headers).forEach(key => xhr.setRequestHeader(key, headers[key]));
};
}
return opts;
},
The key is passing along a content type to force ember-ajax to correctly encode the request body as json.
from ember-graphql-adapter.
Yep, in your adapter.js
you can set the option for POST.
import { Adapter } from 'ember-graphql-adapter';
export default Adapter.extend({
httpMethod: 'POST'
});
from ember-graphql-adapter.
This indeed causes it to make a post request however the body is then sent as a serialized string which is not within the spec.
Following the workaround @cheerfulstoic mentioned in this issue I was able to get it working.
from ember-graphql-adapter.
`import GraphQLAdapter from 'ember-graphql-adapter';
export default GraphQLAdapter.extend({
endpoint: 'https://fakerql.com/graphql',
httpMethod: 'POST',
dataType: 'json',
request: function (store, type, options) {
let compiledQuery = this.compile(store, type, options);
let url = this.endpoint;
let ajaxOpts = this.ajaxOptions({ query: compiledQuery });
ajaxOpts.contentType = 'application/json; charset=utf-8';
return this.ajax(url, ajaxOpts);
},
});`
I got this almost working, just thought it might help
from ember-graphql-adapter.
Related Issues (20)
- README Show graphql syntax used HOT 4
- Parser does not respect primaryKey attribute in serializer
- Compiler should use normalizeCase function from Serializer HOT 1
- Update to latset ember-cli-babel (support node 8) HOT 1
- Can't Identify Input type from server
- Request only fetches ID HOT 3
- Support for aliases?
- GET supports only query operation HOT 2
- An in-range update of ember-ajax is breaking the build 🚨 HOT 3
- Is it possible to push data into the store using pushPayload?
- Readme issue HOT 1
- Constructs incorrect query when gathering a collection that contains a single object. HOT 2
- Release new version with latest commit HOT 1
- Error Handling HOT 5
- Full object graph always requested? HOT 14
- Question regarding added alias for relationships HOT 1
- Are headers supported? HOT 4
- inline fragments support?
- Multiple hasMany relationships generate wrong (nested) query HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-graphql-adapter.