Skip to content
This repository was archived by the owner on Aug 13, 2020. It is now read-only.

Commit b62788f

Browse files
xzyferaf
authored andcommitted
Support graphql@^0.12 (#13)
graphql@^0.12 introduced a breaking change (#1115) which means `execute` is no longer guaranteed to return a Promise. The recommended usage is to always `Promise.resolve()` the result of `execute()`.
1 parent e9a98a7 commit b62788f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const createLocalInterface = (graphql, schema, {rootValue = null, context = null
3232
return Promise.reject(err)
3333
}
3434

35-
return result.then(data => {
35+
return Promise.resolve(result).then(data => {
3636
debug(`${operationName} (${(new Date() - start)}ms)`)
3737
return data
3838
})

tests/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ const {createLocalInterface} = require('..')
33
const test = createGroup()
44

55

6-
const fakeGraphql = {execute: () => Promise.resolve({foo: 'bar'})}
76
const fakeSchema = {}
87

98
test('it doesn\'t blow up for the most basic usage', () => {
9+
const fakeGraphql = {execute: () => Promise.resolve({foo: 'bar'})}
1010
const iface = createLocalInterface(fakeGraphql, fakeSchema)
1111
const result = iface.query({})
1212
return assert.eventually.deepEqual(result, {foo: 'bar'})
1313
})
1414

15+
test('it doesn\'t blow up for non-promise values', () => {
16+
const fakeGraphql = {execute: () => ({foo: 'bar'})}
17+
const iface = createLocalInterface(fakeGraphql, fakeSchema)
18+
const result = iface.query({})
19+
return assert.eventually.deepEqual(result, {foo: 'bar'})
20+
})

0 commit comments

Comments
 (0)