Skip to content

Commit c72cc57

Browse files
author
Richard Keil
committed
add simple test for resolve() arguments
1 parent 22f8778 commit c72cc57

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

test/index.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,53 @@ describe('Using query() syntax', () => {
452452
})
453453

454454
})
455+
456+
it('should pass root and context value', () => {
457+
458+
var rootValue = 'root-value';
459+
var contextValue = 'context-value';
460+
461+
var query = Schema(`
462+
type Person {
463+
id: Int
464+
}
465+
466+
type Query {
467+
person(id: Int!): Person
468+
}
469+
470+
`, {
471+
Query: {
472+
person: function (root, args, ctx, info) {
473+
assert.strictEqual(root, rootValue, 'has incorrect root-value');
474+
assert.strictEqual(ctx, contextValue, 'has incorrect context-value');
475+
return { "id": 1 };
476+
}
477+
}
478+
})
479+
480+
return query(`
481+
query Q($id: Int!) {
482+
person(id: $id) {
483+
id
484+
}
485+
}
486+
`,
487+
{ "id": 1 },
488+
rootValue,
489+
contextValue
490+
).then(res => {
491+
assert.deepEqual(res, {
492+
"data": {
493+
"person": {
494+
"id": 1
495+
}
496+
}
497+
});
498+
})
499+
500+
})
501+
455502
})
456503

457504

0 commit comments

Comments
 (0)