Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
feature(dynamic-context): Execute function for context
Browse files Browse the repository at this point in the history
added test for context function support
  • Loading branch information
matthewerwin committed Sep 14, 2017
1 parent 7ee96e7 commit da03990
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/__tests__/http-test.js
Expand Up @@ -1895,5 +1895,36 @@ describe('test harness', () => {
);
});
});

describe('Custom context capabiility', () => {
it('allows context to be a function', async () => {
const app = server();

get(
app,
urlString(),
graphqlHTTP({
schema: TestSchema,
context: () => Promise.resolve('testValue'),
}),
);

const response = await request(app).get(
urlString({
operationName: 'TestQuery',
query: `
query TestQuery { context }
`,
}),
);

expect(response.status).to.equal(200);
expect(JSON.parse(response.text)).to.deep.equal({
data: {
context: 'testValue',
},
});
});
});
});
});

0 comments on commit da03990

Please sign in to comment.