.then is not a function
diit opened this issue · comments
Dale Inverarity commented
Context
var graphql = require('graphql.js')
var graph = graphql('someurl, {
headers: {
'Authorization': `Bearer XXX`,
'Content-Type': 'application/json'
}
}
function getX() {
return graph('query me { name }')
}
getX().then(me => {
console.log(me)
})
All bundled with webpack, errors on .then call and add the graph.query('...')
does not seem to affect a change.
Expected Result
- Console logs data
Actual Result
- Error on .then
- No network requests made
Fatih Kadir Akın commented
`graph()` returns a function that accepts variables as parameter. You need
to use direct execution. `graph.run()` or `graph.query.run()`
Fatih Kadir Akın commented
```js
getX()(/* variables here as object */).then(me => { console.log(me) })
```
is also valid.
Dale Inverarity commented
That worked!